Skip to content

Instantly share code, notes, and snippets.

@mnahkies
Created April 29, 2016 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnahkies/174d3aa49d8b03d5198853b4234a8f08 to your computer and use it in GitHub Desktop.
Save mnahkies/174d3aa49d8b03d5198853b4234a8f08 to your computer and use it in GitHub Desktop.
Memory usage increases seemingly without bound.
function allocateMemory(len) {
var s = "";
for (var i = 0; i < len; i++) {
s += "x";
}
return s.length;
}
var Threads = require('webworker-threads');
var t = Threads.createPool(2);
t.all.eval(allocateMemory);
function runI(i) {
t.any.eval('allocateMemory(' + i + ')', function (err, result) {
if (err) {
console.error(err.message);
} else if (result && (result % 1000) === 0) {
console.log('result ' + result);
}
});
}
setInterval(function(){
console.log("still alive");
console.log("process.memoryUsage: " + JSON.stringify(process.memoryUsage()));
}, 5000);
for (var i = 0; i < 1000000; i++) {
runI(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment