Basic Steps:
1, Replace new/delete by HeapAlloc/HeapFree;
2, Statistic when allocate and free the memory, special the CallStack when the allocate function has been called;
3, Dump all the non-free allocate calls;
Details:
What are new and operator new and how does they working
http://eli.thegreenplace.net/2011/02/17/the-many-faces-of-operator-new-in-c/
What dose MSDN say
operator new : http://msdn.microsoft.com/zh-cn/library/we2zys4d(v=VS.100).aspx
operator delete : http://msdn.microsoft.com/zh-cn/library/kwsyy0kw.aspx
Replacement memory management : Buildin Type
allocate and free memory : MT_Alloc / MT_Free;
code here;
memory stats : MT_Stats;
code here;
Initialize timing
Useage for init_seg, see MSDN :http://msdn.microsoft.com/zh-cn/library/7977wcck(v=VS.71).aspx
If the application is simple , the timing maybe not importent;
Replacement memory management : STL Type, std::vector for example
implament a allocator like class allocator in <xmemory>, include all of the member functions;
code here;
remark:
1, stl use count, not size, if you want get the size, like this: _Count * sizeof( _Ty);
2, check the std::bad_alloc before call the custom memory allocate function that likeMT_Alloc,just do what dose std::allocator like.
3, replacement new can NOT handle template expression such as new(ptr)(std::vector<int,Allocator_STL<int>>), because it's include "," . Use typedef keyword before that;
What do i do on the Mutli-Thread situcation
Other: Memory Management
What are the memory management libraries already exsit?
How to use Ned Library in my solution.