且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法删除MFC应用程序中的内存泄漏

更新时间:2021-11-26 15:21:11

您***查看代码的内存泄漏.查看泄漏的内存的内容.我猜您不会删除所有分配的子对象.您不会在所有指向数据结构的指针上调用delete" ;-)

在树中,您需要递归地工作,需要多加注意.
you better look at the memory leaks of your code. Look in the content of the leaked memory. I guess that you dont delete all allocated sub-objects. You wont "call delete on all the pointers to the data structs" ;-)

In a tree you need to work recursly what needs a lot of care.


获取消息内存泄漏",并不意味着您存在内存泄漏.这意味着那时的内存消耗只有一些差异.使用MFC时,没有不可避免的泄漏,可能会消耗一些内存.例如,请参见下面的代码

Getting the message "Memory leaked", doesnt mean that you have a memory leak. It means that only some difference is there in memory conumption at that time. When using MFC there are no unavoidable leaks, may be there is some memory consumption. for example see the below code

CMemoryState new, old, diff;
old.CheckPoint();
m_csMyStr.LoadString( IDS_MYSTRING );
old.CheckPoint();
if( diff.Difference( old, new ))
{
    AfxMessageBox( "Mem Leak" );
}



它给出消息"Mem Leak".但是程序员是否需要解决任何内存泄漏问题.没事吧?

但您需要确保所有new完成的操作,只需执行delete
如果调试代码,则可以在Visual Studio IDE本身中找到内存泄漏.在调试窗口中.



It gives the message "Mem Leak". But is there any memory leak that the programmer needs to resove. No right?

but you need to make sure that what all you have newed, you just need to delete
If you debug your code, you can find the memory leak in visual studio IDE itself. In debug window.