首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

使用libxml2时内存泄漏有关问题

2013-09-24 
使用libxml2时内存泄漏问题这段时间写的程序使用了libxml2,现在程序基本上完成了,但是使用内存调试工具运

使用libxml2时内存泄漏问题
这段时间写的程序使用了libxml2,现在程序基本上完成了,但是使用内存调试工具运行时却发现内存有泄漏的问题!
调试的输出是这样的

==28237== 
==28237== HEAP SUMMARY:
==28237==     in use at exit: 5,139 bytes in 96 blocks
==28237==   total heap usage: 10,310 allocs, 10,214 frees, 656,070 bytes allocated
==28237== 
==28237== 15 bytes in 5 blocks are definitely lost in loss record 9 of 46
==28237==    at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==28237==    by 0x414351B: xmlStrndup (in /usr/lib/i386-linux-gnu/libxml2.so.2.7.8)
==28237==    by 0x414359D: xmlStrdup (in /usr/lib/i386-linux-gnu/libxml2.so.2.7.8)
==28237== 
==28237== LEAK SUMMARY:
==28237==    definitely lost: 15 bytes in 5 blocks
==28237==    indirectly lost: 0 bytes in 0 blocks
==28237==      possibly lost: 0 bytes in 0 blocks
==28237==    still reachable: 5,124 bytes in 91 blocks
==28237==         suppressed: 0 bytes in 0 blocks
==28237== Reachable blocks (those to which a pointer was found) are not shown.
==28237== To see them, rerun with: --leak-check=full --show-reachable=yes
==28237== 
==28237== For counts of detected and suppressed errors, rerun with: -v
==28237== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)


问题出在xmlstrdup上,我看了strdup的代码,确实是分配 了空间的了,但是我的代码里确实没有调用这个函数,请问如何查看问题所在,到底是哪个函数调用了xmlstrndup!
求大婶帮忙!! 内存泄漏 strndup 调试
[解决办法]
xmlGetProp —-> xmlStrdup --> xmlStrndup --> malloc 这样的调用关系?

热点排行