Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Add V8 heap info to process.memoryUsage()
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 28, 2009
1 parent 8a58e83 commit 38e425d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion doc/api.txt
Expand Up @@ -110,7 +110,18 @@ The PID of the process.
What platform you're running on. +"linux2"+, +"darwin"+, etc. What platform you're running on. +"linux2"+, +"darwin"+, etc.


+process.memoryUsage()+ :: +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)+:: +process.exit(code=0)+::
Ends the process with the specified code. By default it exits with the Ends the process with the specified code. By default it exits with the
Expand Down
8 changes: 8 additions & 0 deletions src/node.cc
Expand Up @@ -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("rss"), Integer::NewFromUnsigned(rss));
info->Set(String::NewSymbol("vsize"), Integer::NewFromUnsigned(vsize)); 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); return scope.Close(info);
#endif #endif
} }
Expand Down

0 comments on commit 38e425d

Please sign in to comment.