内存泄漏 - 这怎么可能?

时间:2014-05-20 16:46:26

标签: c++ visual-studio-2012 memory-leaks

以下代码会导致内存泄漏:

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

using namespace std;

int main()
{

    _CrtDumpMemoryLeaks();
    return 0;
}

怎么可能?我没有分配任何记忆,我甚至没有构建任何对象...... +

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.

编辑: 找到了。它是:来自BOOST库的BOOST_CLASS_EXPORT_GUID宏(导致内存泄漏)。我用它来序列化。

2 个答案:

答案 0 :(得分:2)

我的通灵调试技巧告诉我,你所包含的一个标题利用导致内存分配的全局变量(直接或通过副作用)。在检查泄漏的调用之前,不会释放该内存。

答案 1 :(得分:0)

我找到了! 找到它是非常复杂的。这是由: BOOST_CLASS_EXPORT_GUID

来自BOOST库的

。删除后 - 没有memleaks! 我会报告。