发表回复 
 
主题评价:
  • 0 次(票) - 平均星级: 0
  • 1
  • 2
  • 3
  • 4
  • 5
scws-0.0.1-pre有内存泄露(问题确认,已解决)
2007年11月27日, 00:50
scws-0.0.1-pre有内存泄露(问题确认,已解决)
mmbb:/usr/src/scws-0.0.1-pre/src# valgrind --tool=memcheck --leak-check=yes ./scwsc -r ../etc/rules.ini -d ../etc/dict.xdb -i "有用过NTFS的朋友抱怨"
==30624== Memcheck, a memory error detector.
==30624== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==30624== Using LibVEX rev 1658, a library for dynamic binary translation.
==30624== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==30624== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==30624== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==30624== For more details, rerun with: -v
==30624==
有用 过 NTFS 的 朋友 抱怨
+--[scwsc(scwsc/0.1.1)]----------+
| TextLen: 20 |
| Prepare: 0.1066 (sec) |
| Segment: 0.0986 (sec) |
+--------------------------------+
==30624==
==30624== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==30624== malloc/free: in use at exit: 6 bytes in 3 blocks.
==30624== malloc/free: 36 allocs, 33 frees, 14,613 bytes allocated.
==30624== For counts of detected errors, rerun with: -v
==30624== searching for pointers to 3 not-freed blocks.
==30624== checked 67,208 bytes.
==30624==
==30624== 6 bytes in 3 blocks are definitely lost in loss record 1 of 1
==30624== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==30624== by 0x804A6F3: (within /usr/src/scws-0.0.1-pre/src/scwsc)
==30624== by 0x8048CE0: (within /usr/src/scws-0.0.1-pre/src/scwsc)
==30624==
==30624== LEAK SUMMARY:
==30624== definitely lost: 6 bytes in 3 blocks.
==30624== possibly lost: 0 bytes in 0 blocks.
==30624== still reachable: 0 bytes in 0 blocks.
==30624== suppressed: 0 bytes in 0 blocks.
==30624== Reachable blocks (those to which a pointer was found) are not shown.
==30624== To see them, rerun with: --show-reachable=yes



mmbb:/usr/src/scws-0.0.1-pre/src# valgrind --tool=memcheck --leak-check=yes ./scwsc -r ../etc/rules.ini -d ../etc/dict.xdb -i "有用过NTFS的朋友抱怨,他们根本感觉不到NTFS所带来的性能提升,甚至觉得适得其反"
==30625== Memcheck, a memory error detector.
==30625== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==30625== Using LibVEX rev 1658, a library for dynamic binary translation.
==30625== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==30625== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==30625== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==30625== For more details, rerun with: -v
==30625==
有用 过 NTFS 的 朋友 抱怨 , 他们 根本 感觉 不到 NTFS 所 带来 的 性能 提升 , 甚至 觉得 适得其反
+--[scwsc(scwsc/0.1.1)]----------+
| TextLen: 76 |
| Prepare: 0.1034 (sec) |
| Segment: 0.1030 (sec) |
+--------------------------------+
==30625==
==30625== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==30625== malloc/free: in use at exit: 26 bytes in 13 blocks.
==30625== malloc/free: 102 allocs, 89 frees, 21,418 bytes allocated.
==30625== For counts of detected errors, rerun with: -v
==30625== searching for pointers to 13 not-freed blocks.
==30625== checked 67,272 bytes.
==30625==
==30625== 26 bytes in 13 blocks are definitely lost in loss record 1 of 1
==30625== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==30625== by 0x804A6F3: (within /usr/src/scws-0.0.1-pre/src/scwsc)
==30625== by 0x8048CE0: (within /usr/src/scws-0.0.1-pre/src/scwsc)
==30625==
==30625== LEAK SUMMARY:
==30625== definitely lost: 26 bytes in 13 blocks.
==30625== possibly lost: 0 bytes in 0 blocks.
==30625== still reachable: 0 bytes in 0 blocks.
==30625== suppressed: 0 bytes in 0 blocks.
==30625== Reachable blocks (those to which a pointer was found) are not shown.
==30625== To see them, rerun with: --show-reachable=yes



mmbb:/usr/src/scws-0.0.1-pre/src# valgrind --tool=memcheck --leak-check=yes ./scwsc -r ../etc/rules.ini -d ../etc/dict.xdb -i "abc def ghi 234"
==30626== Memcheck, a memory error detector.
==30626== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==30626== Using LibVEX rev 1658, a library for dynamic binary translation.
==30626== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==30626== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==30626== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==30626== For more details, rerun with: -v
==30626==
abc def ghi 234
+--[scwsc(scwsc/0.1.1)]----------+
| TextLen: 15 |
| Prepare: 0.1029 (sec) |
| Segment: 0.0498 (sec) |
+--------------------------------+
==30626==
==30626== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==30626== malloc/free: in use at exit: 0 bytes in 0 blocks.
==30626== malloc/free: 12 allocs, 12 frees, 6,024 bytes allocated.
==30626== For counts of detected errors, rerun with: -v
==30626== All heap blocks were freed -- no leaks are possible.

大致说明:分词结果中每成功分出一个汉语词组就发生一次内存未释放。

[[i] 本帖最后由 mfd 于 2007-11-27 10:51 编辑 [/i]]
查找这个用户的全部帖子
引用并回复
2007年11月27日, 00:53
 
我不会c语言,看看哪位能提供解决办法。
查找这个用户的全部帖子
引用并回复
2007年11月27日, 10:50
 
经过咨询hightman,确认scws.c中的_scws_mseg_zone函数有未释放的内存。这个问题已经在2007年8月9日由会员“一口”发现并给出修改补丁,后来因为意外被误清了。
现在将当时的修改方法附上,经过测试,已经不再有泄露了:)

原代码:(scws.c文件404行)
代码:
next_path:
        m = n + 1;
    }
}

在 _scws_mseg_zone 函数结尾增加两个释放:
/* 一口.070808: memory leak fixed. */
if (mpath) free(mpath);
if (npath) free(npath);


修改后应该是这样:
代码:
next_path:
        m = n + 1;
    }

    /* 一口.070808: memory leak fixed. */
    if (mpath) free(mpath);
    if (npath) free(npath);
}
这里再次对hightman的工作和无私奉献表示感谢!
查找这个用户的全部帖子
引用并回复
发表回复 


论坛跳转:


正在浏览该主题的用户: 1 个游客