C++简单内存泄漏检查机制实现(2)_C/C++语言_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

C++简单内存泄漏检查机制实现(2)

作者:黑客防线网安C/C++教程基地 来源:黑客防线网安C/C++教程基地 浏览次数:0

本篇关键词:机制实现检查内存
黑客防线网安网讯:  091 public:  092 Object()  093 {  094 cout << "Object's contructor." << endl;  095 }  096  097 ~Object()  098 {  099 cout << "Object's destructor." ...
  091 public:
  092 Object()
  093 {
  094 cout << "Object's contructor." << endl;
  095 }
  096
  097 ~Object()
  098 {
  099 cout << "Object's destructor." << endl;
  100 }
  101
  102 char data[1024];
  103 };
  104
  105 #define NEW new(__FILE__, __LINE__)
  106
  107 int _tmain(int argc, _TCHAR* argv[])
  108 {
  109 ASSERT(CountOfAllocatedMem() == 0);
  110 Object* pObj = new(buff) Object;
  111
  112 pObj->~Object();
  113
  114 pObj = NEW(Object);
  115 ASSERT(CountOfAllocatedMem() == 1);
  116
  117 delete pObj;
  118 ASSERT(CountOfAllocatedMem() == 0);
  119
  120 pObj = NEW Object;
  121 ASSERT(CountOfAllocatedMem() == 1);
  122 delete pObj;
  123 ASSERT(CountOfAllocatedMem() == 0);
  124
  125 pObj = NEW Object;
  126
  127 char* p = new char[968];
  128 ASSERT(CountOfAllocatedMem() == 2);
  129
  130 DumpUnAllocatedMem();
  131 return 0;
  132 }
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-15009-1.html
网站维护教程更新时间:2012-04-04 22:48:21  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer