RollupJS - JavaScript heap out of memory

Viewed 2624

I know I have a lot of imports of .js files that are data (400K lines) so I suspect that is the problem. Anything that I can do about this?

workbench@1.0.0 build D:\wwwroot\Workbench

rollup -c

scripts/Main.js → bundle.js...

<--- Last few GCs --->

[11428:000001AAB15A09D0]    34674 ms: Mark-sweep 1509.9 (1568.1) -> 1509.8 (1569.1) MB, 1151.5 / 0.0 ms  allocation failure GC in old space requested
[11428:000001AAB15A09D0]    35753 ms: Mark-sweep 1509.8 (1569.1) -> 1509.8 (1538.1) MB, 1078.9 / 0.0 ms  last resort GC in old space requested
[11428:000001AAB15A09D0]    36888 ms: Mark-sweep 1509.8 (1538.1) -> 1509.8 (1538.1) MB, 1135.4 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0000018AA5225729 <JSObject>
    1: split(this=000002F007782201 <Very long string[7147106]>)
    2: guessIndent(aka guessIndent) [D:\wwwroot\Workbench\node_modules\rollup\dist\rollup.js:639] [bytecode=00000237F3924959 offset=11](this=000002F71B0022D1 <undefined>,code=000002F007782201 <Very long string[7147106]>)
    3: new MagicString$1 [D:\wwwroot\Workbench\node_modules\rollup\dist\rollup.js:865] [bytecode=00000237F3923C...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! workbench@1.0.0 build: `rollup -c`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the workbench@1.0.0 build 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:
npm ERR!     C:\Users\ysg4206\AppData\Roaming\npm-cache\_logs\2017-11-22T21_53_17_670Z-debug.log
1 Answers

Basically, one needs to tell node to increase the heap. E.g.

node --max-old-space-size=4096 /path/to/rollup -c

I found this npm utility that adds heap for one or all of your node binary scripts.

https://www.npmjs.com/package/increase-memory-limit

And that solved the problem. Thank you.

Related