Created
May 16, 2013 21:31
-
-
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()
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
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