Skip to content

Instantly share code, notes, and snippets.

@askmike
Last active January 1, 2016 18:29
Show Gist options
  • Save askmike/8183593 to your computer and use it in GitHub Desktop.
Save askmike/8183593 to your computer and use it in GitHub Desktop.
Weird memory behaviour
var _ = require('lodash');
var candles = [];
var c = function() {
console.log('create candle');
_.each(_.range(100000), function(d) {
var candle = {
s: d,
o: Math.random() * 1000,
h: Math.random() * 1000,
l: Math.random() * 1000,
c: Math.random() * 1000,
v: Math.random() * 1000,
p: Math.random() * 1000
};
candles.push(candle);
});
}
var d = function() {
delete candles;
console.log('delete candle');
}
var mem = function() {
console.log('MEMORY:', process.memoryUsage().heapUsed / 1024 / 1024, 'MB');
}
mem();
setInterval(mem, 1000)
setTimeout(function() {
c();
setInterval(c, 1000);
}, 500);
setTimeout(function() {
d();
setInterval(d, 1000);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment