Skip to content

Instantly share code, notes, and snippets.

@felixge
Last active December 17, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixge/5567854 to your computer and use it in GitHub Desktop.
Save felixge/5567854 to your computer and use it in GitHub Desktop.
git bisect start
git bisect bad v2.0.0-alpha8
git bisect good v2.0.0-alpha7
git bisect run node leak.js
var mysql = require( './index' );
var connection = mysql.createConnection({});
var counter = 0;
var sql = 'SELECT 0';
var start = Date.now();
function query() {
var usage = process.memoryUsage().heapUsed / 1024 / 1024;
//console.log(usage);
var duration = Date.now()-start;
if (usage > 50) {
console.log('leak detected: memory usage > 50 MB, took: %d sec', duration/1000);
process.exit(1);
}
if (duration > 5000) {
console.log('no leak detected after 5 sec');
process.exit(0);
}
connection.query(sql, function(err, rows) {
query();
});
};
query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment