Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak #29

Closed
ratanaklun opened this issue Dec 2, 2016 · 3 comments
Closed

Memory Leak #29

ratanaklun opened this issue Dec 2, 2016 · 3 comments

Comments

@ratanaklun
Copy link

I've been trying to find the cause of a memory leak in my application that uses msnodesqlv8 and it seems to be caused by msnodesqlv8. I have the following test code:

const msnodesqlv8 = require('msnodesqlv8');

msnodesqlv8.open('Driver={SQL Server Native Client 11.0};Server=localhost\\SQLEXPRESS;Trusted_Connection=yes;', (err, conn) => {
	if (err) {
		throw err;
	}
	setInterval(() => {
		conn.queryRaw('select 1+1', (err, results) => {
			if (err) {
				throw err;
			}
			console.log(results);
		});
	}, 100);
});

The query executes successfully, but when monitoring the memory usage, the usage just keeps going up until it uses so much the process has to be killed. It does not look like queries are being cleaned up properly.

I took a look into the code and think it might have to do with SQL handles not being freed. I noticed that in the Free method of the OdbcHandle class, handle is set to nullptr before the call to SQLFreeHandle. This would cause the handle to not be freed. (Reference)

@TimelordUK
Copy link
Owner

TimelordUK commented Dec 2, 2016 via email

@TimelordUK
Copy link
Owner

TimelordUK commented Dec 3, 2016

your test was a great help, thanks. This issue should now be corrected in latest version 0.2.11.

Please give it a go and see if it helps.

p.s. I have run your test on Node 6 for 3 hours and memory footprint has not moved.

@ratanaklun
Copy link
Author

Thanks for getting on this issue quickly. Yes, it does seem a lot more stable. Closing for now, but I'll let you know if I experience any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants