Home

Awesome

@nearform/heap-profiler

Package Version Build Status

Heap dump and sample profiler generator for Node.

Installation

Just run:

npm install @nearform/heap-profiler

Preloader

Once installed, the profiler can be used as a preloader that adds a listener to SIGUSR2 signal.

If you start your application like this:

node -r @nearform/heap-profiler index.js

Then you will be able make a snapshot, start profiling heap, and start tracking allocation timeline by sending the process a SIGUSR2 signal, like this:

kill -USR2 $PID

Heap snapshot will be generated immediately.

Heap sampling profiler and allocation timeline must be stopped, by sending another SIGUSR2 signal to the process.

Then the tool will await on the next signal, to resume profiling/tracking/shooting the heap.

The preloader uses the following environment variables to control its behavior:

API

All module functions can be used with promises and by providing a callback as last option.

The promise resolved value (or the callback argument) will be the generated file path.

The available functions are:

Performance impact

Generating a heap dump snapshot is handled synchronously by Node and therefore will block your process completely.

Generating a heap sampling profile or record allocation timeline is instead asynchronous and lightweight. Our test showed that the performance decrease is around 10%.

Contributing

See CONTRIBUTING.md

License

Copyright NearForm Ltd 2020-2022. Licensed under the Apache-2.0 license.