-
-
Save einaros/77654c1d91fd4ff8a7fa to your computer and use it in GitHub Desktop.
This file contains 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 MB = 1024 * 1024; | |
console.log('Initial rss: %d MB', ~~(process.memoryUsage().rss / MB)); | |
(function() { | |
(function() { | |
var buffers = []; | |
(function() { | |
for (var i = 0; i < 5000; ++i) { | |
var buf = new Buffer(65536); | |
buffers.push(buf); | |
for (var x = 0; x < 65536; ++x) buf[x] = 123; | |
} | |
})(); | |
buffers = null; | |
})(); | |
console.log('After closure has completed, buffer array is unreachable, rss: %d MB', ~~(process.memoryUsage().rss / MB)); | |
gc(); | |
setTimeout(function() { | |
gc(); | |
console.log('After two gc calls and 5 second delay, rss: %d MB', ~~(process.memoryUsage().rss / MB)); | |
}, 5000); | |
})(); | |
/* output on node v0.6.14 | |
Initial rss: 9 MB | |
After closure has completed, buffer array is unreachable, rss: 325 MB | |
After two gc calls and 5 second delay, rss: 135 MB | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment