How do I understand the node-memwatch stats data?

1.2k Views Asked by At
{
  "num_full_gc": 17,
  "num_inc_gc": 8,
  "heap_compactions": 8,
  "estimated_base": 2592568,
  "current_base": 2592568,
  "min": 2499912,
  "max": 2592568,
  "usage_trend": 0
}

It's from the memwatch nodejs library:

https://github.com/lloyd/node-memwatch#heap-usage

Which one of these represents the memory used by the script? And what do others mean? The github page doesn't really explain it.

2

There are 2 best solutions below

0
Vynce On

Well, four of them represent the amount of memory used by the script. I think "current_base" is most likely the one you want; I believe it's the amount of memory currently being used by the script. I believe "estimated_base" is the estimate of the typical amount of memory the script uses.

0
Tirolel On

The whole goal of gcstats is to give metrics on memory usage that are more meaningful that simple sampling of RSS size of the heap. Here are what the output fields above mean:

  • num_full_gc is the number of full mark and sweep garbage collection runs that have occurred since the first time gcstats was required.
  • num_inc_gc is the number of times that V8 has performed incremental garbage collection, referred to within V8 as scavenge GC.
  • heap_compactions is the number of times, after a full GC, V8 has actually compacted the heap and free'd allocated memory.
  • usage_trend is a signed magic number that tells the recent percentage change in your heap. This number will be described later.
  • estimated_base is an estimate of the minimum amount of JavaScript heap memory your program uses. That is, over the last several heap compactions, how small did heap shrink to on average.
  • min from the beginning of time, what was the minimum amount of memory your process has used.
  • max same as above, but for maximum.

Credits goes to lloyd hilaiel - http://lloyd.io/is-my-nodejs-program-leaking