gpt4 book ai didi

javascript - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in Ionic 3

转载 作者:可可西里 更新时间:2023-11-01 01:28:04 25 4
gpt4 key购买 nike

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

Screenshot of FATAL ERROR: ineffective mark-compacts near heap limit Allocation failed - JavaScript

最佳答案

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

大多数情况下,当您遇到此错误时,可能是因为内存泄漏、库的添加/版本升级或 Node.js 在不同版本之间管理内存的方式不同(例如,Node.js 版本 <= 10 和 Node. js 版本 > 10)。

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

我有内存泄漏。这是 a great article关于调试 Node.js 中的内存泄漏。

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

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

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

更多示例以进一步说明:

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.

查看max-old-space-size的当前值(以MB为单位)

要查看 max-old-space-size(以 MB 为单位)的当前(不准确但非常接近)值,请在您的终端中运行

node -e 'console.log(v8.getHeapStatistics().heap_size_limit/(1024*1024))'

关于javascript - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in Ionic 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53230823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com