Page 1 of 1

Detected resource leak to early

Posted: Fri Jun 22, 2018 12:02 pm
by MFr
Hello,
i try using madexcept to detect memory leaks. (Tokio)
While debuging i came throu "class function TEncoding.GetUnicode: TEncoding;" in unit unit System.SysUtils where a TUnicodeEncoding is created.
It is freed in class destructor TEncoding.Destroy; but after madexcept reports leaks.
What can i do?

Re: Detected resource leak to early

Posted: Tue Jun 26, 2018 9:48 am
by madshi
madExcept's leak reporting is done in madExcept32.dll, and it should be done after your EXE has already fully finalized (after all the "finalization" sections have run through). So how can that be too early?

Re: Detected resource leak to early

Posted: Mon Jul 02, 2018 1:49 pm
by MFr
Hello,
i don't know how and why. Lets explain.

I have a project named "TestQrtInfrastructure". It requires some packages. In the file "TestQrtInfrastructure.dpr" the uses starts with "madExcept".

When i start the project, the ui appears (DUnit). Then i close the app. Then in this order
- the form disapers
- a small window from madexcept apers to collect leaks
- a windows named madexcept view apears showing leaks
- delphi stoppes at a breakpoint in unit System.SysUtils in class destructor TEncoding.Destroy;

I would expect this order:
- the form disapers
- delphi stoppes at a breakpoint in unit System.SysUtils in class destructor TEncoding.Destroy;
- a small window from madexcept apers to collect leaks
- a windows named madexcept view apears showing leaks

Re: Detected resource leak to early

Posted: Mon Jul 09, 2018 9:08 am
by madshi
Hmmmm... That seems somewhat weird. Two questions:

1) I suppose that breakpoint in System.SysUtils is inside of RTL.bpl?
2) I suppose madExcept is linked into your EXE file? Or are you using madExcept_.bpl as a runtime package?

Re: Detected resource leak to early

Posted: Wed Jul 11, 2018 6:22 am
by MFr
Hm, how do i know?

In "the Event Log" there is a "Module Load: rtl250.bpl. Has Debug Info. ...", therefore i assume yes to 1.

There is a "Module Load: madExcept32.dll ..." too. Can i assume no for 2.?

Now i add "madBasic_;madDisAsm_;madExcept_" to "Runtime Packackes" in the project options, but the problem still occurs.

Re: Detected resource leak to early

Posted: Wed Jul 11, 2018 7:36 am
by madshi
Hmmmm... Can you reproduce this problem in a brand new almost empty test project? That would allow me to reproduce the problem on my PC, which would make it much easier for me to analyze the situation in detail.

Re: Detected resource leak to early

Posted: Sat Sep 15, 2018 2:15 pm
by KobyNudler
i created a new post , but it is the same as
viewtopic.php?f=4&t=28605
the problem is in RTL and MADEXCEPT work too early