node-memwatch
node-memwatch copied to clipboard
discrepancy between 'pm2 monitor', 'top', and memwatch
Just curious why there seems to be such a big difference between the memory consumption reporting by the 2 different tools.
PM2: 64.313 MB Top: 63840 Memwatch current_base: 19793416
Am I missing something here?
I believe the process reserves more memory than the running app is actually using as data. There are various reasons why it does this. At a given point in time, some of this reserved memory might not actually be used by the app.
-
top (and presumably also pm2) are showing the amount of native memory that the process has reserved.
-
memwatch is showing the amount of memory currently used by the heap (all the data currently held by the app).
After a garbage collection, the memory reported by memwatch might drop significantly, although the native memory reserved for the process might not change at all.
Further reading (Sorry the links are for Java, but many of the concepts are the same.)