[fpc-devel] Mem-leak, where?
Sergei Gorelkin
sergei_gorelkin at mail.ru
Wed Sep 26 00:29:45 CEST 2007
Joost van der Sluis wrote:
> ----
> program testbug9751;
>
> {$mode objfpc}{$H+}
>
> uses
> Classes, SysUtils, mysql41dyn;
>
> var hmysql : PMYSQL;
>
> begin
> // InitialiseMysql; <-- remove the comment and the leakage is gone
> repeat
> InitialiseMysql;
> hmysql := nil;
> hmysql := mysql_init(hmysql);
> // Comment the next line and the leakage is gone
> HMySQL:=mysql_real_connect(HMySQL,PChar(''),PChar(''),Pchar(''),Nil,0,Nil,0);
> mysql_close(hmysql);
> ReleaseMysql;
> until 1<0;
> end.
> ----
Looks like mysql_real_connect() overwrites hmysql variable? The value
returned by mysql_init() is not passed to mysql_close(), and the library
may not unload in this case.
If you comment mysql_real_connect(), handle returned by mysql_init() IS
passed to mysql_close().
Sergei
More information about the fpc-devel
mailing list