• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1076
  • Last Modified:

Function call at the end of an application


Is there a way for me to determine which functions/messages are called at the end of an application? That is, I have a memory leak which I'm trying to find and I want to see where the problem is.

3 Solutions

You can try to run the program into debugging mode, using the tools that Visual Studio provides for memory leaks detection.

Pls read http://msdn.microsoft.com/en-us/library/x98tx3cf%28v=vs.80%29.aspx and http://msdn.microsoft.com/en-us/library/c99kz476%28v=vs.80%29.aspx (for MFC).

The object dumps & dumps statistics are pretty effective.
AndyAinscowFreelance programmer / ConsultantCommented:
>>Is there a way for me to determine which functions/messages are called at the end of an application?

The memory leak might be caused by a line of code right at the application start assigning memory which isn't then released.   Don't make ANY assumptions about where it might be.
for an SDI or MDI mfc application the program runs nearly all time in CWinThread::Run where the message loop was performed. you could provide an overload of CWinApp::ExitInstance in your application class which would be called as very last function by the mfc framework.

for a dialog-based mfc application the program exits in InitInstance function of your application class after DoModal call.

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

IssacJonesAuthor Commented:
Hi Andy

I understand what you mean about memory that isn't released. If this is the case how can I find the problem line?

AndyAinscowFreelance programmer / ConsultantCommented:
I'd look at the links provided by incerc, they seem to be relevant.

Look at the output window, it should say what type of object was assigned but not being freed and more info about it.
IssacJonesAuthor Commented:
Thank you all
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now