c++ - memory leak on BOOST_LOG_TRIVIAL using _CrtDumpMemoryLeaks -
i'm using visual studio 2010 , boost library. i'm trying find memory leak using _crtdumpmemoryleaks called after main function exits. i'm pretty sure boost_log_trivial doesn't leak memory. how avoid false positive?
source code:
#define _crtdbg_map_alloc #include <boost/log/trivial.hpp> #include <iostream> #include <stdlib.h> #include <crtdbg.h> _crtmemstate initial_state; _crtmemstate final_state; _crtmemstate state_diff; using namespace std; struct atexit { ~atexit() { _crtmemcheckpoint( &final_state ); if ( _crtmemdifference( &state_diff, &initial_state, &final_state) ) { _crtmemdumpstatistics( &state_diff ); _crtdumpmemoryleaks(); } } } doatexit; void leak_causing_fn() { boost_log_trivial(error) << "module: "; } int main() { _crtmemcheckpoint( &initial_state ); leak_causing_fn(); return 0; } output:
0 bytes in 0 free blocks. 1724 bytes in 47 normal blocks. 4164 bytes in 5 crt blocks. 0 bytes in 0 ignore blocks. 0 bytes in 0 client blocks. largest number used: 5716 bytes. total allocations: 6832 bytes. detected memory leaks! dumping objects -> {359} normal block @ 0x00ad9b90, 4 bytes long. data: < < > 90 3c 00 00 {349} normal block @ 0x00ad98d0, 176 bytes long. data: < d ) > 00 00 00 00 cd cd cd cd 44 e5 29 0f e8 96 ad 00 .....
Comments
Post a Comment