Ask a Question

Allocation profiling in Visual Studio C++ 2005

North-E
Occasional Contributor

Allocation profiling in Visual Studio C++ 2005

Hello!



I test my MFC application in Visual Studio C++ with AQtime 6 for memory leaks using Allocation profiler, and one of the most interesting problems is to detect memory blocks those weren't released manually after application's closing. I can use "Get Results" at any time excluding the moment my code is completed. How can I get results just before garbage collector to free the memory? I thought "Force Garbage Collection" button could help but in my AQtime panel of Visual Studio this button is disabled...
3 REPLIES 3
North-E
Occasional Contributor

Hm, seemed to me that I wasn't too attentive. I created a simple MCF dialog based application right now and added the following code to dialog's OnInitDialog() function:



BOOL CAQtimeTestDlg::OnInitDialog()

{

    CDialog::OnInitDialog();



    // Set the icon for this dialog.  The framework does this automatically

    //  when the application's main window is not a dialog

    SetIcon(m_hIcon, TRUE);           // Set big icon

    SetIcon(m_hIcon, FALSE);       // Set small icon



    malloc(sizeof(int));

    new CButton();

    new int;

    new CMine();



    // TODO: Add extra initialization here



    return TRUE;  // return TRUE  unless you set the focus to a control

}



AQtime detected unreleased memory blocks (including my own CMine class) after application has been closed except CButton instance. Does MFC kills it somehow by itself?
North-E
Occasional Contributor

And an additional question on allocation profiler. I create some profiling including areas, add objects from loaded modules to them, and I have the same profiling results anytime. In some functions call stacks I get only modules those even wasn't included into checked areas. Moreover, I get the same results even if check no areas though I expected to get nothing.

Could anybody explain what is probably wrong?


Hi Dmitriy,





I can use "Get Results" at any time excluding the moment my code is completed. How can I get results just before garbage collector to free the memory? I thought "Force Garbage Collection" button could help but in my AQtime panel of Visual Studio this button is disabled...
Unmanaged C++ does not have a garbage collection mechanism. If you do not release a memory block, it will not be released automatically. The garbage collection is available only for .NET applications.





AQtime detected unreleased memory blocks (including my own CMine class) after application has been closed except CButton instance. Does MFC kills it somehow by itself?
AQtime detects a CButton leak, but it is presented by one of the 'C++ native memory' allocations in the results. You can see this by selecting this allocation in the Report panel and then double-clicking the top item of the call stack displayed in the Details panel.





To see the 'CButton' class name instead of the 'C++ native memory' item in the results, you need to add the module containing definition of this class to your project. In case of Visual Studio 2005, this module is 'mfc80ud.dll'. You can find the location of the module in the Event View panel: just find the record telling that this module has been loaded into the process.





Moreover, I get the same results even if check no areas though I expected to get nothing.

Could anybody explain what is probably wrong?
Please send us your AQtime project along with the results via the Contact Support form. Also please describe the expected results.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: