[fpc-devel] Mem-leak, where?
Joost van der Sluis
joost at cnoc.nl
Wed Sep 26 00:06:39 CEST 2007
About bug 9751. I don't understand where the leak comes from. Take this
Classes, SysUtils, mysql41dyn;
var hmysql : PMYSQL;
// InitialiseMysql; <-- remove the comment and the leakage is gone
hmysql := nil;
hmysql := mysql_init(hmysql);
// Comment the next line and the leakage is gone
This code leaks memory very fast. ;) First I thought that the
InitialiseMysql and ReleaseMysql were leaking. If you remove the first
comment, the leakage is gone. This is because the refcount of the
MySQL-library is increased, so that the library isn't loaded anymore
inside the loop.
But the strange thing is, that if you remove the mysql_real_connect, the
leakage is also gone.
Thus: the InitialiseMySQL and ReleaseMySQL (probably loadlibrary,
unloadlibrary and GetProcedureAddress) procedures are leaking memory,
but only if the library is called in between them. (not all functions,
but some of them)
More information about the fpc-devel