O'Reilly logo

Deploying Node.js by Sandro Pasquali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Profiling processes

When tracing memory leaks and other hard-to-find bugs, it is useful to have profiling tools at the ready. What we will look at in this section is how to take snapshots of running processes and how to draw useful information out of them.

Node already provides some process information natively. Basic tracking of how much memory your Node process is using is easy to fetch with process.memoryUsage():

{ rss: 12361728, heapTotal: 7195904, heapUsed: 2801472 }

There are also modules available to track a little more information on processes. For example, the usage module (github.com/arunoda/node-usage) delivers straightforward memory and CPU usage information. To probe the current process, use the following code:

var usage = require('usage'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required