Permalink
Browse files

Add V8 heap info to process.memoryUsage()

  • Loading branch information...
1 parent 8a58e83 commit 38e425d9bfe3e5fc728576f623fdedf27432f106 @ry ry committed Nov 28, 2009
Showing with 20 additions and 1 deletion.
  1. +12 −1 doc/api.txt
  2. +8 −0 src/node.cc
View
@@ -110,7 +110,18 @@ The PID of the process.
What platform you're running on. +"linux2"+, +"darwin"+, etc.
+process.memoryUsage()+ ::
-Returns the memory usage of the Node process: e.g. +{"rss":5828608,"vsize":3112529920}+
+Returns the memory usage of the Node process. It looks like this
++
+----------------------
+{
+ "rss": 4935680,
+ "vsize": 41893888,
+ "heapTotal": 1826816,
+ "heapUsed": 650472
+}
+----------------------
++
++heapTotal+ and +heapUsed+ refer to V8's memory usage.
+process.exit(code=0)+::
Ends the process with the specified code. By default it exits with the
View
@@ -513,6 +513,14 @@ v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) {
info->Set(String::NewSymbol("rss"), Integer::NewFromUnsigned(rss));
info->Set(String::NewSymbol("vsize"), Integer::NewFromUnsigned(vsize));
+ // V8 memory usage
+ HeapStatistics v8_heap_stats;
+ V8::GetHeapStatistics(&v8_heap_stats);
+ info->Set(String::NewSymbol("heapTotal"),
+ Integer::NewFromUnsigned(v8_heap_stats.total_heap_size()));
+ info->Set(String::NewSymbol("heapUsed"),
+ Integer::NewFromUnsigned(v8_heap_stats.used_heap_size()));
+
return scope.Close(info);
#endif
}

0 comments on commit 38e425d

Please sign in to comment.