Skip to content

Instantly share code, notes, and snippets.

@vorg
Created March 12, 2014 17:24
Show Gist options
  • Save vorg/9511832 to your computer and use it in GitHub Desktop.
Save vorg/9511832 to your computer and use it in GitHub Desktop.
heapdump = require('heapdump')
memwatch = require('memwatch')
memwatch.on 'leak', (info) -> console.log('leak', info)
memwatch.on 'stats', (stats) -> console.log('stats', stats)
if frame % 25 == 1
hd = new memwatch.HeapDiff()
if frame % 25 == 24
diff = hd.end()
if @initialRSS == 0 then @initialRSS = Math.floor(process.memoryUsage().rss/100000)/10
rssDiff = Math.floor((process.memoryUsage().rss/1000000 - @initialRSS)*10)/10
console.log('rss', rssDiff)
totalSum = diff.change.details.map (item) ->
if !totals[item.what] then totals[item.what] = 0
totals[item.what] += item['+']
totals[item.what] -= item['-']
item.what + ' = ' + totals[item.what] + ' +' + item['+'] + ' -' + item['-'] + ' | ' + item.size
#console.log(totalSum)
#console.log('rssDiff/Code', rssDiff, (totals['Code']-220))
if @verbose then console.log(
'diff', diff.change.size,
'curr', diff.after.size,
'rss', Math.floor(process.memoryUsage().rss/100000)/10,
'used', Math.floor(process.memoryUsage().heapUsed/100000)/10,
'total', Math.floor(process.memoryUsage().heapTotal/100000)/10
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment