简体   繁体   中英

Memory leak - how is THAT possible?

THe following piece of code causes a memory leak:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

using namespace std;

int main()
{

    _CrtDumpMemoryLeaks();
    return 0;
}

how is THAT possible? I don't allocate any memory, I even don't construct any object...+

Detected memory leaks!
Dumping objects ->
{168} normal block at 0x006D75D8, 8 bytes long.
 Data: < D      > B8 44 F4 00 00 00 00 00 
{167} normal block at 0x006D7588, 20 bytes long.
 Data: < um  um  um     > 88 75 6D 00 88 75 6D 00 88 75 6D 00 01 01 CD CD 
{166} normal block at 0x006D7538, 20 bytes long.
 Data: < sm  sm  sm     > 10 73 6D 00 A8 73 6D 00 10 73 6D 00 00 00 CD CD 
{165} normal block at 0x006D74E8, 20 bytes long.
 Data: < qm prm  qm     > D8 71 6D 00 70 72 6D 00 D8 71 6D 00 00 00 CD CD 
{164} normal block at 0x006D7498, 20 bytes long.
 Data: <hkm  qm hkm     > 68 6B 6D 00 88 71 6D 00 68 6B 6D 00 00 00 CD CD 
{163} normal block at 0x006D7448, 20 bytes long.
 Data: < jm  km  jm     > 80 6A 6D 00 18 6B 6D 00 80 6A 6D 00 00 00 CD CD 
{162} normal block at 0x006D73F8, 20 bytes long.
 Data: < im 0jm  im     > 98 69 6D 00 30 6A 6D 00 98 69 6D 00 00 00 CD CD 
{161} normal block at 0x006D73A8, 20 bytes long.
 Data: < sm  sm 8um     > 10 73 6D 00 10 73 6D 00 38 75 6D 00 01 00 CD CD 
{160} normal block at 0x006D7360, 8 bytes long.
 Data: <hD      > 68 44 F4 00 00 00 00 00 
{159} normal block at 0x006D7310, 20 bytes long.
 Data: < sm  sm 8um     > A8 73 6D 00 A8 73 6D 00 38 75 6D 00 01 01 CD CD 
{158} normal block at 0x006D72C0, 20 bytes long.
 Data: < im 0jm  im     > 98 69 6D 00 30 6A 6D 00 98 69 6D 00 00 00 CD CD 
{157} normal block at 0x006D7270, 20 bytes long.
 Data: < qm  qm  tm     > D8 71 6D 00 D8 71 6D 00 E8 74 6D 00 01 00 CD CD 
{156} normal block at 0x006D7228, 8 bytes long.
 Data: < D      > 8C 44 F4 00 00 00 00 00 
{155} normal block at 0x006D71D8, 20 bytes long.
 Data: <prm prm  tm     > 70 72 6D 00 70 72 6D 00 E8 74 6D 00 01 01 CD CD 
{154} normal block at 0x006D7188, 20 bytes long.
 Data: <hkm hkm  tm     > 68 6B 6D 00 68 6B 6D 00 98 74 6D 00 01 00 CD CD 
{153} normal block at 0x006D7140, 8 bytes long.
 Data: < D      > CC 44 F4 00 00 00 00 00 
{152} normal block at 0x006D6B68, 20 bytes long.
 Data: < qm  qm  tm     > 88 71 6D 00 88 71 6D 00 98 74 6D 00 01 01 CD CD 
{151} normal block at 0x006D6B18, 20 bytes long.
 Data: < jm  jm Htm     > 80 6A 6D 00 80 6A 6D 00 48 74 6D 00 01 00 CD CD 
{150} normal block at 0x006D6AD0, 8 bytes long.
 Data: <$D      > 24 44 F4 00 00 00 00 00 
{149} normal block at 0x006D6A80, 20 bytes long.
 Data: < km  km Htm     > 18 6B 6D 00 18 6B 6D 00 48 74 6D 00 01 01 CD CD 
{148} normal block at 0x006D6A30, 20 bytes long.
 Data: < rm  im  sm     > C0 72 6D 00 98 69 6D 00 F8 73 6D 00 01 00 CD CD 
{147} normal block at 0x006D69E8, 8 bytes long.
 Data: <DD      > 44 44 F4 00 00 00 00 00 
{146} normal block at 0x006D6998, 20 bytes long.
 Data: < rm 0jm  sm     > C0 72 6D 00 30 6A 6D 00 F8 73 6D 00 01 01 CD CD 
Object dump complete.

edit: found it. It was: BOOST_CLASS_EXPORT_GUID macro from BOOST library (that caused memory leak). I used it for serialization.

My psychic debugging skills tell me that one of the headers you've included utilize global variables who result in memory allocation (directly or through side effects). This memory would not be freed before the call to check for leaks.

I found it! It was extremely complicated to find. It's caused by: BOOST_CLASS_EXPORT_GUID

from BOOST library. After removing it - no memleaks! I'll report it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM