HyperDex icon indicating copy to clipboard operation
HyperDex copied to clipboard

Memleak in node.js binding

Open vitage opened this issue 9 years ago • 4 comments

I test hyperdex example node.js code, and i found that code is not working. I fix bugs and modernize example and start it. Script leaks very fast. And It is not leak in node.js.

Tested on: Ubuntu 14.04 LTS, Calculate linux, Ubuntu 12.04 LTS

var hyperdex_client = require('hyperdex-client')
var hd = new hyperdex_client.Client('127.0.0.1', 1982)

var qlen = 0, count = 0, count_old = 0, err = 0, dt_old = new Date()

var loop = function() {
    var id = 'test_' + parseInt(Math.random()*1000000)
    qlen++;


    hd.get('test_kv', id , function(err){
        if (err) err++;
        count++;
        qlen--;
        return setImmediate(loop)
    })
}

setInterval(function() {
    var dt = new Date()
    var qps = (count - count_old) / (dt - dt_old) * 1000
    count_old = count
    dt_old = dt
    console.log('Processed '+count + ' pids, qps:', qps, 'qlen:', qlen, 'err:', err, Math.round(process.memoryUsage()['heapUsed']/1000/1000),'Mb')
}, 1000)

for (var i = 0; i < 2000; i++) setImmediate(loop)

vitage avatar Aug 27 '14 15:08 vitage

What version of Node are you using, and how did you install the bindings? I'd like to attempt to recreate.

rescrv avatar Aug 27 '14 17:08 rescrv

Hello, i can confirm the memory leak with code above, I have node version v0.10.29 and installed the npm module hyperdex-client

ctimoteo avatar Aug 28 '14 02:08 ctimoteo

With node version 0.10.31 and npm module hyperdex-client memory leak still exists

Hamper avatar Aug 28 '14 15:08 Hamper

I have node version v0.10.31 npm install hyperdex-client

vitage avatar Aug 28 '14 16:08 vitage