IBM / node-red-contrib-db2-for-i

A Node-RED node to read and write to a Db2 for i database from Node-RED on IBM i.
https://flows.nodered.org/node/node-red-contrib-db2-for-i
8 stars 7 forks source link

Memory leak #2

Closed abamara closed 4 years ago

abamara commented 5 years ago

Hello,

I found that there is a possible memory leak. sqlB is declared but never freed

try {

    var sqlB = new db.dbstmt(db2.dbconn);

    sqlB.execSync(msg.payload, function (rows) {

        if (!node.arraymode) {

            rows = rows.length == 0 ? [""] : rows; //issue 0.1.1 - if rows is empty, return an empty row

            rows.forEach(function (row) {

                msg.payload = row;

                node.send(msg);

                // bug - erase msg content corrected 0.0.9 - node.send({ topic: msg.topic, payload: row } );

            })

        }

        else {

            msg.payload = rows;

            node.send(msg);
        }

        //node.send([ null, { topic: msg.topic, control: 'end' }]);
    });

}

sqlB need to be freed like in catch part.

if (sqlB) {
    sqlB.close();
}

delete sqlB;
bmarolleau commented 5 years ago

Hi, indeed. will be corrected in the next release - as soon as possible. Thanks.

bmarolleau commented 4 years ago

Closed . pb solved commit 87e975a