Skip to content

JS heap size increase not working (--max_old_space_size) #4536

@delatitude

Description

@delatitude

Issue

While build or run my project with create-react-app. It throws js heap out of memory error.

`

yarn build
yarn run v1.6.0
$ react-scripts build
Creating an optimized production build...
<--- Last few GCs --->
[8792:0000021D06B28B70] 1492086 ms: Mark-sweep 1401.7 (1716.2) -> 1401.7 (1716.2) MB, 1474.4 / 0.0 ms allocation failure GC in old space requested
[8792:0000021D06B28B70] 1493542 ms: Mark-sweep 1401.7 (1716.2) -> 1401.5 (1658.7) MB, 1455.7 / 0.0 ms last resort GC in old space requested
[8792:0000021D06B28B70] 1494983 ms: Mark-sweep 1401.5 (1658.7) -> 1401.5 (1636.7) MB, 1439.7 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
`

After searching on internet, i found a few suggestions and have added the following lines to my package start and build lines.

"start": "node --max_old_space_size=4096 node_modules/.bin/react-scripts start",
"build": "node --max_old_space_size=4096 node_modules/.bin/react-scripts build"

Now when i run "npm start" or "npm build" i get the following error.
`

npm start
view@0.1.0 start D:\my-apps
node --max_old_space_size=4096 node_modules/.bin/react-scripts start
D:\my-apps\node_modules.bin\react-scripts:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! view@0.1.0 start: node --max_old_space_size=4096 node_modules/.bin/react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ttc-avl-map-view@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:`

Did you try recovering your dependencies?

Yes, the issue exists after deleting node_modules folder and reinstalling through npm

Environment

Environment:
OS: Windows 10 Pro
Node: 8.9.3
Yarn: 1.6.0
npm: 6.1.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.2.0 => 16.4.0
react-dom: ^16.2.0 => 16.4.0
react-scripts: 1.1.4 => 1.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions