Function call at the end of an application

Posted on 2011-02-14
Last Modified: 2013-11-20

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.

Question by:IssacJones

Accepted Solution

incerc earned 84 total points
ID: 34891359

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.
LVL 44

Expert Comment

ID: 34894399
>>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.
LVL 33

Assisted Solution

sarabande earned 83 total points
ID: 34895178
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.

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


Author Comment

ID: 34895341
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?

LVL 44

Assisted Solution

AndyAinscow earned 83 total points
ID: 34895370
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.

Author Closing Comment

ID: 34895400
Thank you all

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ffmpeg - "rtsp://...... Operation not permitted" 4 81
only14 challenge 19 77
wordcount challenge 11 123
Thin secure Windows 10 5 98
In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question