通用编程能力训练:Memory Track(2012-01-29 19:02)
2012-01-29 19:00
337 查看
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.
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.
相关文章推荐
- 通用编程能力训练:发布-订阅模式
- 通用编程能力训练 -- 设计心得:分步载入的改造(包含异步IO练习)
- 通用编程能力训练:template
- 编程能力训练 —— 系列介绍
- Java编程能力强化(2)——搜索解决方案类问题的通用解法
- 编程能力训练 —— 1st C++习题:输入3个数求最大值
- 编程能力训练 —— 2nd C++习题:输入一个成绩判断并输出相应的等级
- 2012_01_29
- 2012-01-29 19:01 Http的KeepAlive最详细的说明文档
- 2012_01_29
- 拟训练自己编程能力
- 通用编程训练-C#延迟赋值函数的实现
- [新手编程训练项目]001——C语言文本合并01
- 2012第三届国信蓝点杯全国软件设计大赛编程大题
- [OGRE]看备注学编程(02):打地鼠01-布置场地九只地鼠
- 3-22个月宝宝生活自理能力训练全记录
- 编程练习3——01
- OpenCV编程->Haar训练(4)
- 提高编程能力的7条建议
- 寒假训练01E:hdu1087