Created
May 3, 2017 04:43
-
-
Save poying/b9bace072ea030e941ddaca55797f721 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
const path = require('path'); | |
const memwatch = require('memwatch-next'); | |
const heapdump = require('heapdump'); | |
const logger = require('./logger'); | |
const settings = require('./config/settings'); | |
memwatch.on('leak', info => { | |
const filepath = path.resolve(settings.HEAP_SNAPSHOT_DIR, Date.now() + '.heapsnapshot'); | |
logger.fatal({ leak: info }, 'Memory leak'); | |
heapdump.writeSnapshot(filepath, err => { | |
if (err) { | |
logger.error({ err }, 'Failed to take heap snapshot'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment