Page 1 of 1

7.0.5 Memory leak

Posted: 09.09.2013, 22:09
by Alfa000
Hello

If i try this simple project, then memory manager generate memory leak mesage:

Code: Select all

program LeakProj;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, ZDbcIntfs, ZDbcMySql;

var
  sConString: string;
  LZeos: IZConnection;
begin

  ReportMemoryLeaksOnShutdown := True;

  sConString := Format('zdbc:%s://%s:%d/%s?UID=%s;PWD=%s', ['mysql-5', '127.0.0.1', 4434, 'aslibex_dunit_zeos', 'root', '']);

  LZeos := DriverManager.GetConnection(sConString);
  LZeos := nil;

end.

I don't know why, but i try break code in finalization part of unit ZDbcMySql

Code: Select all

initialization
  MySQLDriver := TZMySQLDriver.Create;
  DriverManager.RegisterDriver(MySQLDriver);
finalization
  if DriverManager <> nil then
    DriverManager.DeregisterDriver(MySQLDriver);
  MySQLDriver := nil; //<< In this place MySQLDriver ref count have value 2! 
end.                         //<< In this place MySQLDriver ref count have still value 1!  MySQLDriver is never destroyed!
Maybe problem is here: I tried insert breakpoint to method TZAbstractDriver.Destroy but this method was never executed!

Re: 7.0.5 Memory leak

Posted: 10.09.2013, 11:13
by EgonHugeist
I'm not 100% sure yet. But ReportMemoryLeakOnShutDown is an annoying theme:

It doesn't check MemLeaks which are freed after finalization. The IZDriverManager is already alive which contains a clone of the Driver. That's why RefCount > 0.

We're using the FPC HeapTrace-Unit for detecting leaket memory, which btw. tell's us much more about leaked memory than the ReportMemoryLeakOnShutDown of Delphi. I'm planning to add FASTMM4 to our test units...

What makes me wondering: Does the destructore really never be called?

Re: 7.0.5 Memory leak

Posted: 10.09.2013, 15:01
by Alfa000
Ok, i try FastMM4 with full debug mode on this really simple program. This program does allmost nothing. But memory leak is still reported.

Code: Select all

program LeakProj;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  FastMM4, //FullDebugMode enabled
  System.SysUtils, ZDbcIntfs, ZDbcMySql;

var
  sConString: string;
  LZeos: IZConnection;
begin
  sConString := Format('zdbc:%s://%s:%d/%s?UID=%s;PWD=%s', ['mysql-5', '127.0.0.1', 4434, 'aslibex_dunit_zeos', 'root', '']);

  LZeos := DriverManager.GetConnection(sConString);
  LZeos := nil;

end.
MadExcept and EurekaLog still reports memory leak too. I attach reports files from FastMM and MadExcept.

Main point is, that no memory leaks occurs in previous stable version of ZeosLib - 7.0.4.

In this simple program i place four breakpoint into these constructors and destructors:

TZAbstractDriver.Create
TZAbstractDriver.Destroy
TZAbstractConnection.Create
TZAbstractConnection.Destroy

If i use zeoslib 7.0.4 then program stops once in every of these methods.

But if i use zeoslib 7.0.5 then program stops only in constructors.

Sorry for my poor English.

Daniel Andrascik

Re: 7.0.5 Memory leak

Posted: 10.09.2013, 15:19
by EgonHugeist
Have to correct my selves.

Found the bug and did solve this issue.
Patch done R2722 \testing 7.1

Hmpf annoying after releasing 7.0.5, realy. Switch to SVN..

Re: 7.0.5 Memory leak

Posted: 10.09.2013, 16:46
by Alfa000

Re: 7.0.5 Memory leak

Posted: 02.10.2013, 19:02
by fhaut
hi

using the zeos 7.0.5a-stable still remain the memory leak...

Re: 7.0.5 Memory leak

Posted: 02.10.2013, 19:23
by EgonHugeist
Where did you get 7.0.5a from? SVN?

Re: 7.0.5 Memory leak

Posted: 03.10.2013, 12:40
by fhaut
yes

from SVN at svn://svn.code.sf.net/p/zeoslib/code-0/tags/7.0.5a-stable

Re: 7.0.5 Memory leak

Posted: 04.10.2013, 20:33
by fhaut
EgonHugeist

you have found the SVN repository ? or there is a other repository address where the memleak is solved ?

fhaut wrote:yes

from SVN at svn://svn.code.sf.net/p/zeoslib/code-0/tags/7.0.5a-stable

Re: 7.0.5 Memory leak

Posted: 08.10.2013, 22:51
by EgonHugeist

Re: 7.0.5 Memory leak

Posted: 09.10.2013, 12:43
by fhaut
Works fine,

Thank you