Here is sample piece of C++ code compiled and run using VS2010 on Windows XP.
It prints \"private bytes\" before and after allocation.
void PrintPri
Your solution of checking the private bytes is correct, only your assumption about _heapmin is wrong.
_heapmin does not work as documented. _heapmin is documented as "Releases unused heap memory to the operating system."
The implementation (see "\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\heapmin.c") is
int __cdecl _heapmin(void)
{
if ( HeapCompact( _crtheap, 0 ) == 0 ) {
return -1;
}
else {
return 0;
}
}
HeapCompact is documented to normally do quite nothing despite returning the size of the largest free block in the heap. It only does some extra stuff if a special global (debug purpose) flag is used.