#1 2013-09-20 06:53:35

chapa
Member
Registered: 2012-04-30
Posts: 117

recent changes to TSQLLog

Hi ab,

recently I updated the source

I have example declaration in GUI application:

  TMyLog = class (TSQLLog); 

no methods, constructors, destructors.

When shutting down I get AV exception at TSynLog.Destroy when called from GarbageCollectorFree's

FreeAndNil(PObject(GarbageCollectorFreeAndNilList.List[i])^);

on SynCommons finalization.
Debugging shows that

PObject(GarbageCollectorFreeAndNilList[i])^

is nil. Even it is nil, TMyLog leaks, along with other TSQLLog and TObjectList.

It is heavy multithreaded application using the log. If I step through or delay the finalization, many times I do not get the exception.

Do you have any clue what should be the problem or want me to go further with debugging?

Thanks.

Offline

#2 2013-09-20 07:12:37

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: recent changes to TSQLLog

Long time ago I discover problem with Log and heavy multithreaded application. I don't test is it exist in current version, but try to set Log.Family.PerThreadLog := ptOneFilePerThread; In my case it solve the problem.

Offline

#3 2013-09-20 07:29:42

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: recent changes to TSQLLog

It does not helped, setting only ptOneFilePerThread.
If I set usual stuff even my application does not shut down. Some finalization block, maybe at some critical section.

I think the problem is deeper, maybe in so called "Garbage Collector". I get other strange random leaks of mORMot created objects, just analyzing some in FastMM leak reports.

Offline

#4 2013-09-20 08:15:47

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: recent changes to TSQLLog

Try for example 01 - In Memory ORM with ReportMemoryLeaksOnShutdown := True; --> Leaks

I suspect even "uses SynCommons" leaks.
Another example is SynCommons Initialization GarbageCollectorFreeAndNil(SynAnsiConvertList,TObjectList.Create)
Here instance of TObjectList leaks. (not freed on finalization)

Will investigate GarbageCollector, bu I think Ab should have a clue where the problem should be and save me some time smile
Thanks.

Edited: It was my mistake, above initialization and finalization works fine. Sorry

Last edited by chapa (2013-09-20 08:27:21)

Offline

#5 2013-09-20 08:17:54

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: recent changes to TSQLLog

I should also note, that I made following change in GarbageCollectorFree in order to avoid AVs:

      if Assigned(PObject(GarbageCollectorFreeAndNilList.List[i])^) then // note: added by chapa
        FreeAndNil(PObject(GarbageCollectorFreeAndNilList.List[i])^);

Edited: And everything seems working fine, no leaks or AVs so far, but will full test again and report if have any problems.

Last edited by chapa (2013-09-20 08:28:25)

Offline

#6 2013-09-20 08:32:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: recent changes to TSQLLog

Did you try with the latest unstable version?
A lot of fixes have been done about multi-threading.

We also run all regression tests with memory leak reporting set to ON.

For safety, I've added your fix proposal, checking PObject(GarbageCollectorFreeAndNilList.List(i))^ is not nil.

Offline

Board footer

Powered by FluxBB