# memory-leak-heapdump

> do heapdump when memory leak

Latest version **0.1.1** (published 2017-09-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install memory-leak-heapdump
pnpm add memory-leak-heapdump
yarn add memory-leak-heapdump
bun add memory-leak-heapdump
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-09-29 |
| First published | 2017-09-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | wz2cool |
| Maintainers | wz2cool |

## Links

- npm: https://www.npmjs.com/package/memory-leak-heapdump
- Repository: https://github.com/wz2cool/memory-leak-heapdump
- Homepage: https://github.com/wz2cool/memory-leak-heapdump#readme
- Issues: https://github.com/wz2cool/memory-leak-heapdump/issues
- npm.io page: https://npm.io/package/memory-leak-heapdump

## Dependencies (6)

- [q](https://npm.io/package/q.md) ^1.5.0
- [util](https://npm.io/package/util.md) ^0.10.3
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [heapdump](https://npm.io/package/heapdump.md) ^0.3.9
- [dateformat](https://npm.io/package/dateformat.md) ^3.0.2
- [memwatch-next](https://npm.io/package/memwatch-next.md) ^0.3.0

## Recent versions

- 0.1.1 (latest) — 2017-09-29
- 0.1.0 — 2017-09-28
- 0.0.8 — 2017-09-27
- 0.0.7 — 2017-09-27
- 0.0.6 — 2017-09-27
- 0.0.5 — 2017-09-27
- 0.0.4 — 2017-09-27
- 0.0.3 — 2017-09-27
- 0.0.2 — 2017-09-27
- 0.0.1 — 2017-09-27

## README

# memory-leak-heapdump
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![Build Status](https://travis-ci.org/wz2cool/node-memory-leak-heapdump.svg?branch=master)](https://travis-ci.org/wz2cool/node-memory-leak-heapdump)
[![Coverage Status](https://coveralls.io/repos/github/wz2cool/memory-leak-heapdump/badge.svg?branch=master)](https://coveralls.io/github/wz2cool/memory-leak-heapdump?branch=master)
[![npm version](https://badge.fury.io/js/memory-leak-heapdump.svg)](https://badge.fury.io/js/memory-leak-heapdump)  
`memory-leak-heapdump` is based on `memwatch-next` and `heapdump`. It can dump heapsnapshot if memory leak.
  
## Install
`npm install memory-leak-heapdump --save`
  
## Usage
### snapshot
- js
```js
var heapdump = require('memory-leak-heapdump').Heapdump;
heapdump.snapshot('/tmp/test.heapsnapshot')
    .then(function (filepath) {
        console.log('snapshot file path: ', filepath);
    })
    .catch(function (err) {
        console.error(err);
    });
```
- ts
```js
import { Heapdump } from "memory-leak-heapdump";
Heapdump.snapshot("/tmp/test.heapsnapshot")
    .then((filepath) => {
        console.log("snapshot file path: ", filepath);
    })
    .catch((err) => {
        console.error(err);
    });
```

### Watch leak and snapshot
- ts
```js
import { Watcher, WatcherConfig } from "memory-leak-heapdump";
const watcherConfig = new WatcherConfig();
watcherConfig.appName = "targetAppName";
watcherConfig.snapshotDir = "/tmp";
watcherConfig.snapshotMinInterval = 18000; // 3 min interval(avoid cpu usage issue).

const handleSnapshot = (err: Error, filepath: string): void => {
    if (util.isNullOrUndefined(err)) {
        console.info("snapshot file path: ", filepath);
    } else {
        console.error("handleSnapshot: ", err);
    }
};
watcher.snapshotIfLeak(handleSnapshot);
```

---
_Source: https://npm.io/package/memory-leak-heapdump · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
