Last active
January 1, 2016 18:29
-
-
Save askmike/8183593 to your computer and use it in GitHub Desktop.
Weird memory behaviour
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 _ = 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