简体   繁体   English

是否需要在Valgrind中维护仍然可到达的内存?

[英]Do Still Reachable memory need to be tended to in Valgrind?

I've gone through my C program and gotten rid of all of the definite, indirect and possibly lost leaks, but now I'm met with around 6064 bytes worth of reachable memory. 我遍历了C程序,摆脱了所有明确的,间接的和可能丢失的泄漏,但是现在遇到了大约6064字节的可访问内存。

The problem is when I use valgrind to try search for it, i'm basically given a bunch of gibberish, with many references to 'ImageLoader' that I don't think I used directly in my code. 问题是当我使用valgrind尝试搜索它时,我基本上得到了一堆乱码,其中有很多对“ ImageLoader”的引用,我认为我并没有直接在代码中使用。 The only other ones are showing the line number of printf statements. 唯一的其他显示行数printf语句。

So basically i'm wondering if theres a better way to find and neutralise the still reachable leaks? 因此,基本上我想知道是否有更好的方法来查找和消除仍然可以达到的泄漏? or If I even need to? 还是我什至需要?

Thanks For the Help! 谢谢您的帮助!

Still reachable memory are generally nothing to be too worried about, your program is shutting down anyway when the memory is still reachable so those memories would be cleaned away by the OS. 仍然可访问的内存通常不需要太担心,在仍然可以访问的内存中,您的程序始终会关闭,因此操作系统会清除这些内存。

However, a having still reachable memory may be hiding the situation where you have external resources that need to be properly cleaned before your program quits. 但是,仍然具有可访问的内存可能掩盖了您的外部资源需要在程序退出之前进行正确清理的情况。 If your program does not use any external resources, then you generally don't need to be worried about it. 如果您的程序不使用任何外部资源,那么您通常不必担心它。

A still-reachable memory usually is in main function, global, or static variables. 仍可访问的内存通常位于主要函数,全局变量或静态变量中。

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

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