w1nk/node-odbc — Issue #13: Memory leak
Author: Nibbler999
Created: 2012-01-15 14:42:58+00:00
State: open

I created the following script to call a stored procedure on a remote mssql server (not under my control) using data from an http request. It's leaking memory with each request/query. Any suggestions?

```js

var odbc = require("odbc");
var db = new odbc.Database();

db.open("DSN=fiscal;UID=;PWD=", function(err)
{
if (err) {
console.log(err.message);
return;
}

require('http').createServer(function (req, res) {

res.end();

var parts = require('url').parse(req.url, true);
var matches = parts.pathname.match('^/([a-zA-Z_]+)/$');

if (matches) {

var procedure = matches[1];
var p = parts.query;

var query = "declare @outcome int;"
+ " exec " + procedure + " " + p.bsID + ", " + p.ticketid + ", " + p.amount + ", @outcome OUT;"
+ " select @outcome";

db.query(query, function(err, rows, moreResultSets)
{
if (err) {
console.log(err.message);
} else {
console.log(rows);
}
});

} else {
console.log('Unable to parse request');
}

}).listen(8082, "127.0.0.1");
});

process.on('uncaughtException', function (err) {
console.log('uncaughtException:' + err);
console.log(err.stack);
});
```

I am using node 0.6.7 on CentOS5.