Detected resource leak to early

delphi package - automated exception handling
Post Reply
MFr
Posts: 4
Joined: Fri Jun 22, 2018 11:22 am

Detected resource leak to early

Post 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?
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Detected resource leak to early

Post 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?
MFr
Posts: 4
Joined: Fri Jun 22, 2018 11:22 am

Re: Detected resource leak to early

Post 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
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Detected resource leak to early

Post 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?
MFr
Posts: 4
Joined: Fri Jun 22, 2018 11:22 am

Re: Detected resource leak to early

Post 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.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Detected resource leak to early

Post 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.
KobyNudler
Posts: 10
Joined: Sat Oct 08, 2016 1:55 pm

Re: Detected resource leak to early

Post 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
Post Reply