获取node.js应用程序的最大堆大小 [英] get the max heap size of a node.js application
问题描述
现在我正在paas平台中使用node.js.并且容器有内存限制.现在,我想获取node.js应用程序的最大堆大小.我知道使用参数"--max-old-space-size"可以设置最大堆大小,但是我想知道如何获取默认值"--max-old-space-size".例如,如果容器的内存为512m,则node.js堆大小的最大值不能大于它.我如何获得价值?
Now I am using node.js in paas platform. And the container has memory limit. Now I want to get the maximum of the heap size of node.js application. I know that use the parameter "--max-old-space-size", I can set the max heap size, but I want to know how to get the default value of "--max-old-space-size". For example, if the container's memory is 512m , so the maximum of node.js heap size can not be greater than it. How can I get the value?
推荐答案
您可以尝试使用v8
模块,该文档在此处记录: https://nodejs.org/api/v8.html
You can try the v8
module, it is documented here: https://nodejs.org/api/v8.html
我相信getHeapStatistics()
函数将为您提供所需的一切
I believe getHeapStatistics()
function will give you everything you need
这篇关于获取node.js应用程序的最大堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!