Memory leaks lead to server crashes and performance issues. Also, when too many objects are created, GC may cause performance problems by taking to much CPU time.
To discover memory leaks in Node.js it is possible to use V8's command line tool to access V8's built-in heap profiler.
Nodetime's memory profiling feature uses V8's built-in heap profiler, which allows to take heap snapshots. The snapshots are then analyzed by Nodetime and presented in a form, which leads to faster memory leak detection.
If you have Nodetime running, taking a heap snapshot is just a press of a button. Just make sure you're running version 0.2.12 or newer. To install Nodetime, see instructions.
Here is how a heap snapshot will look like in web console. You can see leakExample property, which points exactly to the leaking objects.

If you're planning to use this feature in production, beware that node process memory and cpu usage will increase during snapshot taking. The feature is still experimental.
You might also want to check out Nodetime's CPU profiling feature, which helps to locate the parts of your code, which waste CPU time.
UPDATE: Memory profiler has been updated. Read more about the new features in this post Memory Profiler Update.

Comments