yarn build -w yields JavaScript heap out of memory
Problem Description
Watching for changes in files results (using yarn build -w) seems to use a lot of memory. Several files can be process but it later fails.
This is the log:
<--- Last few GCs --->
[80357:0x110000000] 163462 ms: Scavenge 2000.1 (2050.8) -> 1999.4 (2050.8) MB, 6.7 / 0.0 ms (average mu = 0.171, current mu = 0.004) allocation failure
[80357:0x110000000] 163479 ms: Scavenge 2000.5 (2051.0) -> 2000.0 (2051.3) MB, 7.1 / 0.0 ms (average mu = 0.171, current mu = 0.004) allocation failure
[80357:0x110000000] 164305 ms: Mark-sweep 2000.6 (2051.5) -> 1994.3 (2051.5) MB, 823.5 / 0.0 ms (average mu = 0.229, current mu = 0.300) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x100717ef9]
Security context: 0x01e594040919 <JSObject>
1: /* anonymous */(aka /* anonymous */) [0x1e5535e5719] [/Users/miguelrincon/workspace/gitlab/gitlab-ui/node_modules/@babel/core/lib/config/config-chain.js:~238] [pc=0xcad887be5b](this=0x01e5ff3c04d1 <undefined>,0x01e5ec6fbb91 <Object map = 0x1e5e9446da9>,0x01e58b1c1441 <Object map = 0x1e5e8c68279>,0x01e5ff3c04d1 <undefined>)
2: loadPresetDescriptor(aka...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Temporary solution
Increasing the memory allocated to node can help to run this process:
NODE_OPTIONS="--max-old-space-size=8192" yarn build -w