Skip to content

Instantly share code, notes, and snippets.

@kylegetson
Created May 16, 2013 21:31
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 kylegetson/5595268 to your computer and use it in GitHub Desktop.
Save kylegetson/5595268 to your computer and use it in GitHub Desktop.
memory leak example in levelup. Repeatedly getting the same key from leveldb. This will consume 100M in memory within 45 seconds, and continues to grow the more you call db.get()
var levelup = require('levelup')
, crypto = require('crypto');
var db = levelup('./mydb', {cacheSize: 0});
// assuming this key exists
var str = "whatever";
var hash = crypto.createHash('md5').update( str ).digest("hex");
function sameGet(num){
if( num == 0 ) return;
db.get(hash, function(err,result){
if( err )
console.log( err);
return sameGet(--num);;
});
}
sameGet(5000000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment