Javascript |堆内存不足服务器端

时间:2018-08-23 14:56:59

标签: javascript jenkins heap-memory

在jenkins中运行构建时,出现错误“ Javascript |内存不足”。我们在本地遇到了类似的问题,并且通过设置节点--max-old-space-size = 8192解决了该问题。我们如何在服务器端摆脱相同的局面?

1 个答案:

答案 0 :(得分:0)

如果您使用Package.json文件,请尝试以下操作。 也许可以解决您的问题。

"scripts": { "start": "node --max-old-space-size=8192 app.js , }

您必须根据需要更改“开始”中的其他选项。

例如,您可以使用自己的文件代替app.js,或者 您也可以像下面一样设置命令而无需任何文件名。

"scripts": { "start": "node --max-old-space-size=8192, }

如果需要任何帮助,请告诉我。

--max-old-space-size is use for set "old space" memory limit, means garbage collection or heap where all javascript objects are available.
So for solve the issue of memory you have to exceeds the limit of memory.
For example, if your server machien have 2 GB of memory, than you can set --max-old-space-size to around 1.5 GB, so other memory is available to perform other tasks.

如果您正在使用Node js应用程序,也可以使用以下选项。

https://www.npmjs.com/package/increase-memory-limit