致命错误:接近堆限制的无效标记压缩分配失败 - Ionic 3 中的 JavaScript 堆内存不足 [英] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in Ionic 3

查看:24
本文介绍了致命错误:接近堆限制的无效标记压缩分配失败 - Ionic 3 中的 JavaScript 堆内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 ionic serve 命令运行 Ionic 3 项目时,我收到此错误:

When I run an Ionic 3 project using the ionic serve command, then I am getting this error:

推荐答案

对于那些从 Google 提出这个问题的人的非 Angular 通用答案:

For a non-Angular general answer for those who land on this question from Google:

每次遇到此错误时,可能是因为内存泄漏或 Node.js <= 10 和 Node.js > 之间的差异;10 管理内存.

Every time you face this error it’s probably because of a memory leak or difference between how Node.js <= 10 and Node.js > 10 manage memory.

通常只是增加分配给 Node.js 的内存可以让你的程序运行但实际上可能无法解决真正的问题并且节点进程使用的内存仍然可能超过你分配的新内存.我建议在 Node.js 进程开始运行或更新到 Node.js 时分析它的内存使用情况 >10.

Usually just increasing the memory allocated to Node.js will allow your program to run but may not actually solve the real problem and the memory used by the node process could still exceed the new memory you allocate. I'd advise profiling memory usage in your Node.js process when it starts running or updating to Node.js > 10.

我有内存泄漏.这是关于在 Node 中调试内存泄漏的一篇很棒的文章.js.

I had a memory leak. Here is a great article on debugging memory leaks in Node.js.

也就是说,要增加内存,请在运行 Node.js 进程的终端中:

That said, to increase the memory, in the terminal where you run your Node.js process:

export NODE_OPTIONS="--max-old-space-size=8192"

max-old-space-size 的值可以是:[2048, 4096, 8192, 16384] etc

where values of max-old-space-size can be: [2048, 4096, 8192, 16384] etc

更多示例以进一步清晰:

More examples for further clarity:

export NODE_OPTIONS="--max-old-space-size=5120" # Increase to 5 GB
export NODE_OPTIONS="--max-old-space-size=6144" # Increase to 6 GB
export NODE_OPTIONS="--max-old-space-size=7168" # Increase to 7 GB
export NODE_OPTIONS="--max-old-space-size=8192" # Increase to 8 GB

# and so on...

# formula:
export NODE_OPTIONS="--max-old-space-size=(X * 1024)" # Increase to X GB

# Note: it doesn't have to be multiples of 1024.
# max-old-space-size can be any number of memory megabytes (MB) you have available.

这篇关于致命错误:接近堆限制的无效标记压缩分配失败 - Ionic 3 中的 JavaScript 堆内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆