There is a big project written in C++. Some gui action (button click) allocates 2 MB of memory. It is not a memory leak, course the memory is freed later. But I need to investigate what objects are allocated to try to reduce memory allocation size.
So I tried to use debug crt
OnBtnClick()
{
//breakpoint1
_CrtMemState s1;
_CrtMemCheckpoint( &s1 );
//The logic itself
_CrtMemDumpAllObjectsSince(&s1);
_CrtMemState s2;
_CrtMemCheckpoint( &s2 );
_CrtMemState s3;
if ( _CrtMemDifference( &s3, &s1, &s2) )
_CrtMemDumpStatistics( &s3 );
//breakpoint2
}
The debug report says that only 400 KB were allocated. But process memory in task manager between 2 breakpoints increased by 2 MB.
So, created dump is useless. Can you explain me where is the rest memory allocation?
Try a simple test of creating an overloaded Global New and Delete operators that logs every request to a file. You can turn logging on/off using the state of a static global. This will give you an instrument to log each memory allocation you can expect to control.