Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added syntax highlighting to readme #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,41 @@ node-heapdump
Make a dump of the V8 heap for later inspection.

### Install

npm install heapdump
```bash
npm install heapdump --save
```

Or, if you are running node.js v0.6 or v0.8:

npm install heapdump@0.1.0
```bash
npm install heapdump@0.1.0 --save
```

### Build

node-gyp configure build
```bash
node-gyp configure build
```

### Usage

Load the add-on in your application:

var heapdump = require('heapdump');
```js
const heapdump = require('heapdump');
```

The module exports a single `writeSnapshot([filename], [callback])` function
that writes out a snapshot. `filename` defaults to
`heapdump-<sec>.<usec>.heapsnapshot` when omitted.

heapdump.writeSnapshot('/var/local/' + Date.now() + '.heapsnapshot');
```js
heapdump.writeSnapshot('/var/local/' + Date.now() + '.heapsnapshot');
```

The function also takes an optional callback function which is called upon
completion of the heap dump.

heapdump.writeSnapshot(function(err, filename) {
console.log('dump written to', filename);
});
```js
heapdump.writeSnapshot(function(err, filename) {
console.log('dump written to', filename);
});
```

The snapshot is written synchronously to disk. When the JS heap is large,
it may introduce a noticeable "hitch".
Expand All @@ -42,18 +48,21 @@ making it effectively asynchronous. However, it broke the comparison view in
Chrome DevTools and is fundamentally incompatible with node.js v0.12. If you
really want the old behavior and know what you are doing, you can enable it
again by setting `NODE_HEAPDUMP_OPTIONS=fork` in the environment:

$ env NODE_HEAPDUMP_OPTIONS=fork node script.js
```bash
$ env NODE_HEAPDUMP_OPTIONS=fork node script.js
```

On UNIX platforms, you can force a snapshot by sending the node.js process
a SIGUSR2 signal:

$ kill -USR2 <pid>
```bash
$ kill -USR2 <pid>
```

The SIGUSR2 signal handler is enabled by default but you can disable it
by setting `NODE_HEAPDUMP_OPTIONS=nosignal` in the environment:

$ env NODE_HEAPDUMP_OPTIONS=nosignal node script.js
```bash
$ env NODE_HEAPDUMP_OPTIONS=nosignal node script.js
```

### Inspecting the snapshot

Expand Down