Node.JS process uses 1.4 GB of memory, but heapdump is only 300 MB

狂风中的少年 提交于 2019-12-06 04:21:52

问题


I'm running a Socket.IO server with Node.JS, which normally uses about 400 MB of memory, because there's a lot of data being cached to send to clients. However, after a couple of hours it suddenly starts growing to 1.4 GB of usage over about 40 minutes. Someone told me to use heapdump to find if there is a memory leak.

The problem is that the heapdump only turned out to be 317 MB and nothing in it looks out of the ordinary, so I'm stuck with debugging. I've also run it with nodetime, which says that the V8 heap usage is around 400 MB, but the total V8 heap size is 1.4 GB.

How do I find out where the remaining 1 GB comes from?


回答1:


Maybe node-memwatch could help you?

https://github.com/lloyd/node-memwatch

From its Readme:

node-memwatch is here to help you detect and find memory leaks in Node.JS code. It provides:

A leak event, emitted when it appears your code is leaking memory.

A stats event, emitted occasionally, giving you data describing your heap usage and trends over time.

A HeapDiff class that lets you compare the state of your heap between two points in time, telling you what has been allocated, and what has been released.



来源:https://stackoverflow.com/questions/22712220/node-js-process-uses-1-4-gb-of-memory-but-heapdump-is-only-300-mb

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