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.

Who is Participating?

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

Pls read and (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.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.

All Courses

From novice to tech pro — start learning today.