JavaScript heap out of memory
·
1 min read
·
96
Words
·
-Views
-Comments
Problem
Recently during Angular development involving build packaging, JIT packaging worked fine, but when doing AOT packaging, it reported JavaScript heap out of memory
and memory overflow, as shown below:
After investigation, this issue can be resolved by setting higher memory space.
Solution
Increase max_old_space_size
For example, in my case where webpack packaging script commands are defined in package.json, it looks like this:
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js"
After making this change, the packaging works fine.
Notes
- Memory unit is
MB
- AOT compared to JIT has an additional ngc compilation step, so it does consume more memory.