Created
April 16, 2013 22:53
-
-
Save geek/5400349 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ChildProcess = require('child_process'); | |
var maxMem = Math.round(process.memoryUsage().rss / (1024 * 1024)) * 2; | |
console.time('leak'); | |
setInterval(function () { | |
ChildProcess.exec('echo', function () { | |
var mem = Math.round(process.memoryUsage().rss / (1024 * 1024)); | |
console.log(mem + 'M used'); | |
if (mem >= maxMem) { | |
console.log('Memory has doubled since process started'); | |
console.timeEnd('leak'); | |
process.exit(); | |
} | |
}); | |
}, 100); | |
/* | |
Output: | |
12M used | |
12M used | |
12M used | |
. | |
. | |
. | |
21M used | |
22M used | |
Memory has doubled since process started | |
leak: 52601ms | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment