#1 2014-08-11 13:14:54

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Memory leaks in TSynLog?

I've got memory leaks in TSynLog, looks like the problem is from GarbageCollectorFreeAndNil()

The version I'm using: mORMot and Open Source friends 2014-07-16 0910

I assume My derived TSynLog class doesn't affect this?

stack traces by madExcept - I got a lot of entries like this:

allocation number: 38186
type: AnsiString
address: $b1e3318
size: 46
access rights: read/write
code page: 65001
reference counter: 1
string length: 32
contents: AllocNewSequentialFeedMediumPool

thread $17ec (TOmniThread):
671cb40a madExcept32.dll madExceptDbg          1500 GetMemCallback
00406a94 MyProgram.exe   System                4189 @GetMem
0040a6a7 MyProgram.exe   System               22313 @NewAnsiString
0040a8f2 MyProgram.exe   System               23046 @LStrFromPCharLen
0069e6a7 MyProgram.exe   SynCommons           39226 ReadSymbol
0069f69e MyProgram.exe   SynCommons           39461 LoadMab
0069f958 MyProgram.exe   SynCommons           39504 TSynMapFile.Create
006a20b4 MyProgram.exe   SynCommons           40802 TSynLog.LogFileHeader
0052b98a MyProgram.exe   System.Classes        6915 TStream.Seek
006a2e87 MyProgram.exe   SynCommons           40906 TSynLog.LogHeaderLock
006a349f MyProgram.exe   SynCommons           40999 TSynLog.LogInternal
006a1c69 MyProgram.exe   SynCommons           40697 TSynLog.Log

memory dump: 
0b1e3318  e9 fd 01 00 01 00 00 00 - 20 00 00 00 41 6c 6c 6f  ........ ...Allo
0b1e3328  63 4e 65 77 53 65 71 75 - 65 6e 74 69 61 6c 46 65  cNewSequentialFe
0b1e3338  65 64 4d 65 64 69 75 6d - 50 6f 6f 6c 00 00        edMediumPool..

Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2014-08-11 13:18:17

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

Re: Memory leaks in TSynLog?

We have never seeen such leak with the default class.

Are you sure you are using it in the standard way?

We need simple code to reproduce the issue.

Offline

#3 2014-08-12 05:53:10

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Memory leaks in TSynLog?

Ab, quite standard, except I use a derived class:
http://synopse.info/forum/viewtopic.php?id=1891

One thing came to my mind - I free the logger object manually, I not sure if that affects GarbageCollectorFreeAndNil()


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2014-08-12 07:17:46

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

Re: Memory leaks in TSynLog?

We do not use nor test manually handled TSynLog, just class-level TSynLog instances.

Your derived class is mixing both single instance (T*Log.Create) and class-level parameters (using Family).
I suppose this is breaking everything.

Offline

#5 2014-08-13 03:33:33

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Memory leaks in TSynLog?

ab, i need to do that because each thread must has its own log file.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2014-08-13 07:06:30

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

Re: Memory leaks in TSynLog?

Why not use PerThreadLog := ptOneFilePerThread ?

Offline

#7 2014-08-13 07:31:12

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Memory leaks in TSynLog?

Arnaud, it's a little more complex then that, - I also need to control the log file name, so that:
- I can load the most recent log entries the next time my program runs.
- Imagine my program has a concept called "profile" - I keep only one log file for each "profile" in my program.

Can I achieve that without using a derived class I mentioned above? Thanks!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#8 2014-08-13 07:49:32

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

Re: Memory leaks in TSynLog?

AFAIR you can not use a TSynLog class instance, without accessing its per-class TSynLogFamily settings.

In this case, sub-class you own TSynLog type, then use it as you which in your own application.

Offline

#9 2014-08-15 18:41:01

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Memory leaks in TSynLog?

Update 1: Downloaded the latest svn from github, the memory leaks are gone smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#10 2014-08-15 20:58:50

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

Re: Memory leaks in TSynLog?

Rule 1: always download the latest "unstable" version from GitHub, our fossil repository, or http://synopse.info/files/mORMotNightlyBuild.zip
smile

Offline

#11 2014-08-16 05:45:36

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Memory leaks in TSynLog?

Arnaud, yes, you are right smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB