如何检测内存泄漏 int _CrtSetDbgFlag( int newFlag );

来源:互联网 发布:淘宝店铺优惠券怎么弄 编辑:程序博客网 时间:2024/05/16 20:12

 

   #include   <crtdbg.h>
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); 

Retrieves or modifies the state of the _crtDbgFlag flag to control the allocation behavior of the debug heap manager (debug version only).  

The _CrtSetDbgFlag function allows the application to control how the debug heap manager tracks memory allocations by modifying the bit fields of the _crtDbgFlag flag. By setting the bits (turning on), the application can instruct the debug heap manager to perform special debugging operations, including checking for memory leaks when the application exits and reporting if any are found, simulating low-memory conditions by specifying that freed memory blocks should remain in the heap's linked list, and verifying the integrity of the heap by inspecting each memory block at every allocation request. When _DEBUG is not defined, calls to _CrtSetDbgFlag are removed during preprocessing.

原创粉丝点击