别看我的diff了,意义不大,下面是valgrind的输出,看这个完全就可以了。 读config文件有好几处泄漏。 另外一次性泄漏也是泄漏,不能大意。 这里是一次性,但如果有人想移植到别的地方(比如我就想把recoll原来的ngram替换掉)可就不一定是一次性了。
==6467== 24 bytes in 2 blocks are definitely lost in loss record 1 of 7 ==6467== at 0x4023D6E: malloc (vg_replace_malloc.c:207) ==6467== by 0x8057A24: mmap_file (csr_mmap.c:58) ==6467== by 0x804D1CD: css::SynonymsDict::load(char const*) (SynonymsDict.cpp:46) ==6467== by 0x804B765: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:164) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== ==6467== 1,677 (20 direct, 1,657 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 7 ==6467== at 0x4021E22: calloc (vg_replace_malloc.c:397) ==6467== by 0x805D27A: dictionary_new (dictionary.c:129) ==6467== by 0x8058D76: iniparser_load (iniparser.c:554) ==6467== by 0x804B46C: css::SegmenterManager::loadconfig(char const*) (SegmenterManager.cpp:72) ==6467== by 0x804B807: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:180) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== ==6467== 121 bytes in 9 blocks are indirectly lost in loss record 3 of 7 ==6467== at 0x4023D6E: malloc (vg_replace_malloc.c:207) ==6467== by 0x805D574: xstrdup (dictionary.c:71) ==6467== by 0x805D6F4: dictionary_set (dictionary.c:276) ==6467== by 0x8059236: iniparser_load (iniparser.c:599) ==6467== by 0x804B46C: css::SegmenterManager::loadconfig(char const*) (SegmenterManager.cpp:72) ==6467== by 0x804B807: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:180) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== ==6467== 171 bytes in 1 blocks are definitely lost in loss record 4 of 7 ==6467== at 0x402309E: operator new[](unsigned) (vg_replace_malloc.c:268) ==6467== by 0x804A554: segment(char const*, css::Segmenter*) (mmseg_main.cpp:246) ==6467== by 0x804AF10: main (mmseg_main.cpp:220) ==6467== ==6467== ==6467== 512 bytes in 1 blocks are indirectly lost in loss record 5 of 7 ==6467== at 0x4021E22: calloc (vg_replace_malloc.c:397) ==6467== by 0x805D2B9: dictionary_new (dictionary.c:135) ==6467== by 0x8058D76: iniparser_load (iniparser.c:554) ==6467== by 0x804B46C: css::SegmenterManager::loadconfig(char const*) (SegmenterManager.cpp:72) ==6467== by 0x804B807: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:180) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== ==6467== 512 bytes in 1 blocks are indirectly lost in loss record 6 of 7 ==6467== at 0x4021E22: calloc (vg_replace_malloc.c:397) ==6467== by 0x805D2A6: dictionary_new (dictionary.c:134) ==6467== by 0x8058D76: iniparser_load (iniparser.c:554) ==6467== by 0x804B46C: css::SegmenterManager::loadconfig(char const*) (SegmenterManager.cpp:72) ==6467== by 0x804B807: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:180) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== ==6467== 512 bytes in 1 blocks are indirectly lost in loss record 7 of 7 ==6467== at 0x4021E22: calloc (vg_replace_malloc.c:397) ==6467== by 0x805D293: dictionary_new (dictionary.c:133) ==6467== by 0x8058D76: iniparser_load (iniparser.c:554) ==6467== by 0x804B46C: css::SegmenterManager::loadconfig(char const*) (SegmenterManager.cpp:72) ==6467== by 0x804B807: css::SegmenterManager::init(char const*, unsigned char) (SegmenterManager.cpp:180) ==6467== by 0x804AEAA: main (mmseg_main.cpp:212) ==6467== ==6467== LEAK SUMMARY: ==6467== definitely lost: 215 bytes in 4 blocks. ==6467== indirectly lost: 1,657 bytes in 12 blocks. ==6467== possibly lost: 0 bytes in 0 blocks. ==6467== still reachable: 0 bytes in 0 blocks. ==6467== suppressed: 0 bytes in 0 blocks. |