如何检查内存的释放 [英] How to check deallocation of memory

查看:188
本文介绍了如何检查内存的释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查指针p指向的内存是否已成功解除分配?

How to check if memory to which pointer p points has been succesfully deallocated?

推荐答案

t。

查看 Valgrind 等工具,帮助您调试

Check out tools like Valgrind to help you debugging memory leaks issues.

其他一些你应该考虑的事情:

Some other things you should consider:


  • 使用智能 c>删除 $ c>没有效果,

  • 使用标准类(向量,...)而不是滚动自己的< >
  • 最后,不要使用指针(实际上你几乎可以)

  • Use smart pointers so that you don't have do think about memory management,
  • Set your pointers to 0 after you free them, so that a further delete has no effect,
  • Use standard classes (vector, ...) instead of rolling your own,
  • Finally, don't use pointers (actually you almost can)

这篇关于如何检查内存的释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆