简体   繁体   English

如何修复Valgrind日志中的内存泄漏

[英]how fix memory leaks from Valgrind log

This is the first time i have seen a valgrind log , this log is provided by other users (i can't run valgrind , since it's not supported stlinux (sh4) 这是我第一次看到valgrind日志,这个日志是由其他用户提供的(我不能运行valgrind,因为它不支持stlinux(sh4)

for learning how could fix memory leak with valgrind log , would highly appreciated if any expert , choose even one line of bellow's valgrind error log (and tell us , the valgrind error line he intends for fix and post their fix (patch of source code) 为了学习如何使用valgrind日志修复内存泄漏,如果有任何专家,请高度赞赏,甚至选择一行波纹管的valgrind错误日志(并告诉我们,他打算修复的valgrind错误行并发布他们的修复程序(源代码补丁)

then , would learn how we could fix memory leak from valgrind log , and i would do all rest fixing myself (i just need a example fix) 然后,我将学习如何修复valgrind日志中的内存泄漏,我会自行修复自己(我只需要一个示例修复)

here is the app trac browser (source code) : http://www.streamboard.tv/oscam/browser/trunk/?rev=5375 这是app trac浏览器(源代码): http//www.streamboard.tv/oscam/browser/trunk/? verv = 5375

would highly appreciate if any expert would take a look at these log (i really need help) , here are 4 valgrind logs : 非常感谢任何专家看看这些日志(我真的需要帮助),这里有4个valgrind日志:

http://www.4shared.com/office/04seUumN/valgrind_ 2 .html http://www.4shared.com/office/04seUumN/valgrind_ 2 .html

http://www.4shared.com/office/WYmfxICb/valgrindlog.html http://www.4shared.com/office/WYmfxICb/valgrindlog.html

http://www.4shared.com/office/WGwlKeUK/valgrind.html http://www.4shared.com/office/WGwlKeUK/valgrind.html

http://www.4shared.com/office/mkX4FAzd/valgrind_ 1 .html http://www.4shared.com/office/mkX4FAzd/valgrind_ 1 .html

PS : PS:

  1. since i can't run valgrind myself , please choose a memory leak with largest memory loss (leaks) , then , i could monitor those improvement with my eyes (top command , ps -aux) 因为我不能自己运行valgrind,请选择内存泄漏最大的内存丢失(泄漏),然后,我可以用我的眼睛监视这些改进(top command,ps -aux)

  2. my concern for fixing memory leaks , are mostly limited to these modules (for me the priority (importance) is in their number sequence ( i mean , fixing a memory leak with module-datastruct-list.c is in top priority for me , ....) 我对修复内存泄漏的担心主要局限于这些模块(对我而言,优先级(重要性)是在它们的数字序列中(我的意思是,使用module-datastruct-list.c修复内存泄漏是我的首要任务,。 ...)

    • module-datastruct-list.c 模块datastruct-list.c
    • oscam-garbage.c oscam-garbage.c
    • oscam.c oscam.c
    • module-cccam.c 模块cccam.c
    • module-dvbapi.c 模块dvbapi.c

Thanks in advance 提前致谢

I used Valgrind a long time ago so I don't remember well how to use it, but I know it is fairly easy. 很久以前我用Valgrind所以我不记得如何使用它,但我知道这很容易。 Valgrind logs show every memory leak of the program, due to your code, but also due to code you call from libraries. Valgrind日志显示程序的每个内存泄漏,由于您的代码,但也由于您从库调用的代码。 For every leak, the function call stack is displayed, like this : 对于每个泄漏,都会显示函数调用堆栈,如下所示:

==5313== Invalid write of size 4
==5313==    at 0x8048A27: test_2() (valgrind-tests.cc:37)
==5313==    by 0x8048CDF: main (valgrind-tests.cc:134)
==5313==    by 0x215BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==5313==    by 0x8048910: (within /home/newren/examples/valgrind-tests)
==5313==    Address 0x1B3E024 is 0 bytes inside a block of size 4 free'd
==5313==    at 0x5419C5: __builtin_delete (vg_replace_malloc.c:244)
==5313==    by 0x5419E3: operator delete(void*) (vg_replace_malloc.c:253)
==5313==    by 0x8048A20: test_2() (valgrind-tests.cc:36)
==5313==    by 0x8048CDF: main (valgrind-tests.cc:134)
==5313==    by 0x215BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==5313==    by 0x8048910: (within /home/newren/examples/valgrind-tests)

This means you try to write 4 bytes in memory, but you don't have access to theses bytes. 这意味着您尝试在内存中写入4个字节,但您无法访问这些字节。 This issue is located at line 37 of "valgrind-tests.cc" in this example. 此问题位于此示例中“valgrind-tests.cc”的第37行。

The main problem of valgrind is that, as I said earlier, it displays memory leaks or memory warnings (like forgotten pointers) from libraries you use. valgrind的主要问题是,正如我之前所说,它会显示您使用的库中的内存泄漏或内存警告(如忘记的指针)。 To clean your logs, you can write valgrind rule files called " suppression files ". 要清理日志,可以编写名为“ 抑制文件 ”的valgrind规则文件。

More informations here and here . 这里这里有更多的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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