JavaScript heap out of memory

JavaScript heap out of memory

7月 22, 2017 · 1 分钟阅读时长 · 96 字 · -阅读 -评论

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:

out of memory

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.
Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源