VC本身就可以检查程序里堆中内存的泄露,对于GDI资源那就要自己小心了。
解决方案 »
- 关于字符串的处理问题,这是查找cpp文件中正文中含有中文的函数,排除注释中出现的中文,ListShow(strLine,i)是显示这一行行数和这一行的内容
- 关于cnnectex 的数量问题。
- 求ADO中查询结果转成txt文件的方案。
- 如何将View中Child类型视图的边框显示出来?
- CFileDialog dlg(false);打开时怎样给文件名编辑框赋初值?
- 双线程读写ado access数据库问题?谢谢!
- 我学过 c++但没多少经验,想学vc 需要多长时间才能达到一般公司的要求?
- 有没有高手能帮我呀?
- 为什么基类中的数据成员不可用
- 如何处理主视类。谢谢
- 关于开发一个数据库控件问题???
- 高分请教高手__VC+网络
After you perform the memory allocation and deallocation operations, create another CMemoryState object and call Checkpoint for that object to get a current snapshot of memory usage.
Create a third CMemoryState object, call the Difference member function, and supply the previous two CMemoryState objects as arguments. The return value for the Difference function will be nonzero if there is any difference between the two specified memory states, indicating that some memory blocks have not been deallocated.
The following example shows how to check for memory leaks:// Declare the variables needed
#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" );
}
#endifNotice that the memory-checking statements are bracketed by #ifdef _DEBUG / #endif blocks so that they are compiled only in Win32 Debug versions of your program.
how to find BoundChecker?Thanks!