Created
April 29, 2016 06:07
-
-
Save mnahkies/174d3aa49d8b03d5198853b4234a8f08 to your computer and use it in GitHub Desktop.
Memory usage increases seemingly without bound.
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
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