简体   繁体   English

监视Node.js进程以获取每个进程的最大内存使用率

[英]Monitoring Node.js processes for max memory usage per process

I'd like to monitor any node.js process that pops up on my machine and eventually print out the maximum memory used by the process when the process dies. 我想监视我的计算机上弹出的任何node.js进程,并在进程死后最终打印出该进程使用的最大内存。 Is there any monitoring software that does this already and if not, what is the best way to go about doing this? 是否有任何监视软件已经在执行此操作,如果没有,执行此操作的最佳方法是什么?

Since I know which type of Node.js processes I want to monitor, I could put a check ( setInterval ) inside each process and then just log the maximum memory used that way. 由于我知道我要监视的Node.js进程类型, 因此可以在每个进程中放入一个check( setInterval ),然后以这种方式记录使用的最大内存。 I believe I can access the amount of memory used via process.memoryUsage() and just store the maximum amount and log that upon exit using process.on('exit') . 我相信我可以通过process.memoryUsage()访问使用的内存量,并存储最大的内存量,并在使用process.on('exit')时记录process.on('exit')

However, is there a way to monitor a group of node.js processes somehow? 但是,有没有办法以某种方式监视一组node.js进程? How do I know which group I am looking at? 我怎么知道我在看哪个小组? In other words, how can I mark certain node.js processes so that I can monitor different groups? 换句话说,如何标记某些node.js进程,以便可以监视不同的组?

Check StrongLoop Arc: https://strongloop.com/strongblog/node-js-performance-heap-profiling-tip/ 检查StrongLoop Arc: https ://strongloop.com/strongblog/node-js-performance-heap-profiling-tip/

You can add title to your processes using process.title . 您可以使用process.title将标题添加到流程中。 You may also want to check memwatch . 您可能还需要检查memwatch And finally, check this blog post: http://blog.yld.io/2015/08/10/debugging-memory-leaks-in-node-js-a-walkthrough/ 最后,查看此博客文章: http : //blog.yld.io/2015/08/10/debugging-memory-leaks-in-node-js-a-walkthrough/

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM