Allocation profiling in Visual Studio C++ 2005
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2010
11:35 PM
05-19-2010
11:35 PM
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...
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2010
02:05 AM
05-20-2010
02:05 AM
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?
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2010
05:22 PM
05-23-2010
05:22 PM
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?
Could anybody explain what is probably wrong?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2010
04:52 AM
06-03-2010
04:52 AM
Hi Dmitriy,
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.
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...
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.
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?
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.
Please send us your AQtime project along with the results via the Contact Support form. Also please describe the expected results.
Moreover, I get the same results even if check no areas though I expected to get nothing.
Could anybody explain what is probably wrong?
--
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
