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?
It looks like I have found out the cause of the problem.
On button click several richedit windows controls were created and filled with data. Windows probably allocates memory bypassing runtimes. So we don't see its allocations in dbgcrt report. But when I close richedit handles, memory is successfully released.
So, I will try to use one common richedit for all button clicks.
Thanks everyone for help!