|
楼主 |
发表于 2008-4-1 12:30:16
|
显示全部楼层
- #include <iostream>
- #include <windows.h>
- #include <crtdbg.h>
- #include <malloc.h>
- using std::endl;
- osg::ref_ptr<osg::Node> createSceneGraph();
- int
- main( int argc, char** argv )
- {
- int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); //为了跟踪检测;
- tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
- _CrtSetDbgFlag( tmpFlag );
- osg::Node* node1=new osg::Node();
- osg::Node* node2=new osg::Node();
- return 0;
- }
复制代码 上面我做了一个测试;没有delete,也不能delete;调试的时候,当推出main函数,就检测到内存泄漏:- Detected memory leaks!
- Dumping objects ->
- {777} normal block at 0x00E65AD8, 24 bytes long.
- Data: < > 20 AC 15 00 FF FF FF FF 00 00 00 00 00 00 00 00
- {776} normal block at 0x00E65A90, 8 bytes long.
- Data: < = Z > 9C FB 3D 10 D8 5A E6 00
- {775} normal block at 0x00E659A0, 176 bytes long.
- Data: < B Z > 94 87 42 00 90 5A E6 00 00 00 00 00 00 00 00 00
- {774} normal block at 0x00E65948, 24 bytes long.
- Data: < > E8 AB 15 00 FF FF FF FF 00 00 00 00 00 00 00 00
- {773} normal block at 0x003EB530, 8 bytes long.
- Data: < = HY > 9C FB 3D 10 48 59 E6 00
- {772} normal block at 0x00E65858, 176 bytes long.
- Data: < B 0 > > 94 87 42 00 30 B5 3E 00 00 00 00 00 00 00 00 00
- Object dump complete.
复制代码 |
|