Created
March 12, 2014 17:24
-
-
Save vorg/9511832 to your computer and use it in GitHub Desktop.
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
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