有谁知道如何检测末个模块中是否有内存泄漏(又没有什么好的工具)我的程序GDI不断增加,不知道如何降低GDI数量,有谁能说说在程序运行中gdi与那些因素有关,谢谢!
解决方案 »
- 关于CDC的用法(原则性问题)
- ■■■VC程序内存不断增加的问题(见详细描述)
- 序列化的概念问题,请指教......
- 如何挂起一个时钟发生器
- 关于邮件中多语言码转换的问题?
- detours-iexplore
- mfc与WinMain(),到底是怎样link上的???
- 有关拦截send API 的问题!
- 谁能给我用DAO读写access的范例?请给我一些讲解(越详细越好,有书也行)
- 紧急求助:如何用VC将文本信息用图像表示出来?
- JPEG编码
- fatal error C1010: unexpected end of file while looking for precompiled header directive 是什么错误啊?
l 在你所检测的程序段的开始处建立一个CmemoryState对象,调用其成员函数Checkpoint,以取得当前内存使用情况的快照;
l 在你所检测的程序段的末尾处再建立一个CmemoryState 对象,调用其成员函数Checkpoint ,以取得当前内存使用情况的快照;
l 再建立第三个CmemoryState 对象,调用其成员函数Difference,把第一个CmemoryState对象和第二个CmemeoryState对象作为其参数.,如果两次内存快照不相同,则该函数返回非零,说明此程序 段中有内存漏洞。
#ifdef _DEBUG
CMemoryState oldMemState, newMemState, diffMemState;
OldMemState.Checkpoint();
#endif
// do your memory allocations and deallocations...
CString s = "This is a frame variable";
// the next object is a heap object
CPerson* p = new CPerson( "Smith", "Alan", "581_0215" );
#ifdef _DEBUG
newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{
TRACE( "Memory leaked!\n" );
}
#endif