Skip to content

Instantly share code, notes, and snippets.

@subzey
Created September 20, 2012 08:29
Show Gist options
  • Select an option

  • Save subzey/3754672 to your computer and use it in GitHub Desktop.

Select an option

Save subzey/3754672 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node --harmony
var map = new WeakMap();
var heapStat = {
current: undefined,
max: -Infinity
};
(function iterate(){
console.log(
'Current: %s\tMax: %s',
heapStat.current = process.memoryUsage().heapUsed,
heapStat.max = Math.max(heapStat.current, heapStat.max)
); // Show Stats
map.set(
{}, // New object as key
{foo: Array(65535).join(0)} // New bulk object as value
);
setTimeout(iterate, 0); // More GC-friendly than process.nextTick
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment