Take Heapdump and save them into S3
meteor add arunoda:heapsave
var heapsave = HeapSave.toS3('access-key', 'access-secret', 'bucket');
function saveHeap(){
var saveName = 'myapp-' + Date.now();
heapsave(saveName);
}
// Save heapdump after 1 minute
Meteor.setTimeout(saveHeap, 1000*60);
// Save heapdumps every hour
Meteor.setInterval(saveHeap, 1000*60*60);
- In order to get a heapdump you need to have at least twice of Memory on the system. So it's better to turn on swap if you are running under a low memory server.
- Every heapdump will cause v8 to call
gc()
. It is a blocking operation. - Heapdump will be saved to disk using a child_process.
- Heapdump will be compressed before sending it to s3. Compression also done via a child process.
- refer node-heapdump project for more information
Heapdumps can be analyzed using Chrome dev tools.
- download your dumps from s3
- untar them
- load them into chrome dev tool under "profiles" tab
- learn how to analyze heap and detect memory leaks
Written by Arunoda from Kadira. Meteor 1.2 support added by the Nitrolabs team.