Jump to content
Sign in to follow this  
TurboMagic

ReportMemoryLeaksOnShutdown := true no longer working

Recommended Posts

Hello,

 

we have a Tokyo based Win32 project where ReportMemoryLeaksOnShutdown := true; as first line in the dpr does not lead to any leaks being reported on shutdown of the program,

even if we force a leak in FormCLose of the main form (we can prove that the lines are executed there.

 

In a small test application memory leak reporting works fine.

 

What can this be?

In the same project something has gone wrong with FastMM4 anyway. Small rpointer of records (size 12 bytes) do consume over 1K RAM each!

Any clue what this could be? If extracted into the small test project it doesn't consume too much RAM. Same data type, same loop etc.

 

Best regards

TurboMagic

Share this post


Link to post
41 minutes ago, David Heffernan said:

Nothing has gone wrong with FastMM and memory leak reporting works fine. 

How's that?

Will creating some object in FormClose but not freeing it there not leak?

Share this post


Link to post

I do know that leak reporting normally works, but it doesn't in this specific project. The project is a bigger one with
a 5-digit number of LOC so creating a minimal demo, as much as I understand why you want it, is not so easy.

 

Are there any known issues which can interfere with it?

We already checked and confirmed that there is only one ReportMemoryLeaksOnShutdown := true; line as first line
in the dpr's main program.

 

We also tried FastMM491 and included FastMM4 ias first unit in the dpr's uses clause, but it didn't change anything.
We also had tried V4.97, but that did not compile. There was some data type mismatch somewhere.

Share this post


Link to post

Leak reporting works fine. I guess your code doesn't have a leak. Throw in a call to GetMem and see how that goes. 

Share this post


Link to post

Ahem, the following code I had used to test will leak:

 

var

  sl : TStringList;

begin

  sl := TStringList.Create;

  sl.Add('This will leak David!');

  sl.Add('This will leak David!');

end;

 

See: no free, thus it will leak at least one TStringList.

 

I had even put that construct into the dpr and put an exit after the last Add call, so the application quit immediately. But it didn't show any message box.

Ok, doing that in the dpr and thus not running any VCL initialisation made in the dpr's main code migt be problematic for showing a message box,
but the code above was in the FormClose event of the main form and got called!

Share this post


Link to post

Do you have anywhere in your finalization sections something which could trigger a silent exitprocess?

Share this post


Link to post
9 hours ago, TurboMagic said:

Ahem, the following code I had used to test will leak:

 

var

  sl : TStringList;

begin

  sl := TStringList.Create;

  sl.Add('This will leak David!');

  sl.Add('This will leak David!');

end;

 

See: no free, thus it will leak at least one TStringList.

 

I had even put that construct into the dpr and put an exit after the last Add call, so the application quit immediately. But it didn't show any message box.

Ok, doing that in the dpr and thus not running any VCL initialisation made in the dpr's main code migt be problematic for showing a message box,
but the code above was in the FormClose event of the main form and got called!

Those are reported as leaks for me. As I said, we need a minimal reproduction. 

Share this post


Link to post

I would also expect that they are reported to me and in other big applications I have they actually are, but not in this one and reducing this might not be so easy.

 

@Attila: what in my finalization sections could trigger a silend exit process? Do y<ou have any examples so I know what to look for?

Share this post


Link to post
10 minutes ago, TurboMagic said:

I would also expect that they are reported to me and in other big applications I have they actually are, but not in this one and reducing this might not be so easy.

 

@Attila: what in my finalization sections could trigger a silend exit process? Do y<ou have any examples so I know what to look for?

Calls to ExitProcess or TerminateProcess.

 

My experience however is that guesswork is not much of a basic for solving problems. My experience is that debugging is way more effective. My advice is that you debug your problem. Cutting down to a minimal reproduction is one way to start doing that. 

Share this post


Link to post
10 hours ago, TurboMagic said:

But it didn't show any message box.

Is it possible, that somehow your application is flagged as console application? Because then it prints the leak report to the stderr 

Edited by Stefan Glienke

Share this post


Link to post

I'll check this, but I doubt it as it is a VCL application. How can I check this? {$AppType CONSOLE}?

Share this post


Link to post

Thanks for that hint, we'll do that later. First we try to run this project on a different machine to see if it happens there as well.

Edited by TurboMagic

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×