get the max heap size of a node.js application

筅森魡賤 提交于 2019-12-22 08:46:29

问题


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?


回答1:


You can try the v8 module, it is documented here: https://nodejs.org/api/v8.html

I believe getHeapStatistics() function will give you everything you need




回答2:


you can use the process.memoryUsage https://nodejs.org/api/process.html#process_process_memoryusage



来源:https://stackoverflow.com/questions/33418987/get-the-max-heap-size-of-a-node-js-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!