Comments (8)
+ìnfinity
from node-memwatch.
When our leak is detected, the app is using about 1GB of RAM. Each heap snapshot takes about 8 seconds. The diff (which we trigger on the next GC) takes 52 seconds!
Diffing is a synchronous process right? That means our server is blocking all requests while the diff is being processed. That's unacceptable for production. So currently we only report "leak detected" in production, and try to reproduce on a dev machine for heap snapshots and diffing.
What would be really great:
- Instead of starting and ending a HeapDiff, save two HeapSnapshots to a file. (Accept the 8 second hit for each.)
- Diff the two heaps in a separate process (e.g. a shell command the developer can execute).
Is that possible now? Or is it planned? Thanks!
from node-memwatch.
@jackycute The diffing can still be useful on a development machine, but in staging (and sometimes production) I am now using this approach:
After memwatch reports a possible leak, I use 'heapdump' to take 5 snapshots after each of the next 5 GCs.
const memwatch = require('memwatch-next');
const heapdump = require('heapdump');
const maxHeapDumpsToSave = 5;
let leakDetected = false;
let numHeapDumpsSaved = 0;
memwatch.on('leak', function (info) {
console.warn(new Date(), "Possible memory leak detected:", info);
leakDetected = true;
// We leave it to the 'stats' event to snapshot and diff heaps
// We don't do it here because it can be a very long time between two 'leak' events,
// resulting in large and different heaps.
});
memwatch.on('stats', function (d) {
if (leakDetected && numHeapDumpsSaved < maxHeapDumpsToSave) {
console.warn(new Date(), "Dumping the heap...");
const filename = `./heapdump-${process.pid}-${numHeapDumpsSaved}.heapsnapshot`;
heapdump.writeSnapshot(filename, () => {
console.warn(new Date(), "Heap dump completed.");
});
numHeapDumpsSaved++;
}
});
When these files appear on disk, I use Chrome devtools to compare them. (The UI for this changed recently, but you can drag files into the devtools pane, or hit Cmd-O
/ Ctrl-O
.)
from node-memwatch.
- Can
node-memwatch
be used in production environment? - Which best practices should be used to detect memory leaks (may be also with
v8-profiler
)
from node-memwatch.
@hellboy81 I've used memwatch(-next)
to trigger heapdump
with very good results so far. Saved me a ton of debugging.
from node-memwatch.
I'll include heapdump as enhancement to allow automatic dumps on memwatch events (configurable)
from node-memwatch.
+1
from node-memwatch.
Agreed with @joeytwiddle
The diffing is blocking and takes long time.
from node-memwatch.
Related Issues (20)
- discrepancy between 'pm2 monitor', 'top', and memwatch HOT 1
- can't install on node 8.x HOT 3
- Rename this repository to `memwatch-next`?
- Heap usage: `int` and `time_t` are used instead of `size_t` by mistake HOT 1
- No dump generated on Node 6.9.1 + BeanStalk
- Create Pre-builds
- Cannot install in Node 8.9.4
- Cannot install on node 10.0.0 HOT 6
- cannot install memwatch-next for node v8.x HOT 3
- Error installing it in the Docker alipine node 8.11.4 image HOT 3
- For those needing node 9.x+ support HOT 1
- Install failure on osx Mojave HOT 2
- cannot install on node v11.8.0 HOT 13
- spurious message on start
- Cannot install on node version 12.13.1 HOT 5
- Can't install on Node v13.6.0 with npm 6.13.4, 'Handle': is not member of 'v8' HOT 1
- Memory leaks issue
- Please mark as deprecated HOT 4
- cannot install on MacOS HOT 1
- not able to install
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-memwatch.