Skip to content

Probably there is memory leak after select is executed #40

Description

@miktam

I use 0.3.0 version, with node 0.8.19

var oracle = require("oracle");
var memwatch = require('memwatch');

  oracle.connect({ "hostname": "..." }, function(err, connection) {

      var hd = new memwatch.HeapDiff();
      connection.execute("SELECT * FROM db_table", [], function(err, results) {
        console.log("got results from db: " + results.length);

        console.log("deallocate result manually - just to make sure that results is cleared!");
        for (var i = 0; i< results.length; i++) {
          results[i] = null;
          delete results[i];
        }

        connection.close(); // call this when you are done with the connection
        var diff = hd.end();
        console.log(JSON.stringify(diff, null, 2));
      });
    }

memwatch report:

{
    "after": {
        "nodes": 259291, 
        "size": "10.77 mb", 
        "size_bytes": 11289632, 
        "time": "2013-05-15T12:22:21.000Z"
    }, 
    "before": {
        "nodes": 137578, 
        "size": "6.52 mb", 
        "size_bytes": 6837160, 
        "time": "2013-05-15T12:22:20.000Z"
    }, 
    "change": {
        "allocated_nodes": 121786, 
        "details": [
            {
                "+": 3271, 
                "-": 22, 
                "size": "296.65 kb", 
                "size_bytes": 303768, 
                "what": "Array"
            }, 
            {
                "+": 1, 
                "-": 0, 
                "size": "72 bytes", 
                "size_bytes": 72, 
                "what": "Closure"
            }, 
            {
                "+": 125, 
                "-": 9, 
                "size": "23.07 kb", 
                "size_bytes": 23624, 
                "what": "Code"
            }, 
            {
                "+": 6228, 
                "-": 0, 
                "size": "583.88 kb", 
                "size_bytes": 597888, 
                "what": "Date"
            }, 
            {
                "+": 37380, 
                "-": 0, 
                "size": "584.06 kb", 
                "size_bytes": 598080, 
                "what": "Number"
            }, 
            {
                "+": 3122, 
                "-": 0, 
                "size": "73.17 kb", 
                "size_bytes": 74928, 
                "what": "Object"
            }, 
            {
                "+": 71647, 
                "-": 14, 
                "size": "2.73 mb", 
                "size_bytes": 2865328, 
                "what": "String"
            }
        ], 
        "freed_nodes": 73, 
        "size": "4.25 mb", 
        "size_bytes": 4452472
    }
}

Please note String allocation.
memwatch invokes gc before taking the diff of the heap, and also if you will run this code in a loop, you will see noticable leak as soon as results are pretty big.

I'm looking at the native code right now, if will be able to fix, will make a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions