[英]Increase memory limit in nodejs
I am trying to increase memory limit in node, so I added an environment variable我正在尝试增加节点中的 memory 限制,所以我添加了一个环境变量
it does not work not sure why I also tried it with capital letters here is how I test it它不起作用不知道为什么我也用大写字母尝试过这里是我如何测试它
const maxHeapSz = require('v8').getHeapStatistics().heap_size_limit;
const maxHeapSz_GB = (maxHeapSz / 1024 ** 3).toFixed(1);
console.log(`${maxHeapSz_GB}GB`);
I keep gettin 2GB, I'm trying to get 8GB我一直在获取 2GB,我正在尝试获取 8GB
I appreciate any help我很感激任何帮助
You can use您可以使用
node --max-old-space-size=8192 app.js
It's work for me!这对我有用!
Result:结果:
node --max-old-space-size=8192 test.js
8.0GB
The actual memory that is consumed by the application (in the form of objects in the JavaScript heap) is represented by heapUsed field in process.memoryUsage() API.应用程序消耗的实际 memory(以 JavaScript 堆中的对象的形式)由 process.memoryUsage() ZDB974238714CA8DE634A7CE1D083A1 中的 heapUsed 字段表示
You can check for more information here .您可以在此处查看更多信息。 This article also shows methods to increase the maximum heap size.本文还展示了增加最大堆大小的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.