bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reclaiming memory before exit, take 2


From: Bruno Haible
Subject: Re: reclaiming memory before exit, take 2
Date: Sat, 16 May 2020 19:12:15 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Hi Tim,

> When talking about finding memory leaks, like in your wiki page, you
> should also mention static analyzers and their ability to find memory
> leaks (clang static analyzer, gcc-10 -fanalyzer, Coverity, cppcheck, ...).

Would you like to add one or more wiki pages about these static analyzers?

> These are able to find leaks (and much more) even in code that is seldom
> used during runtime (and perhaps never during testing).
> To find all those leaks with runtime tools like valgrind, you need  a
> very high code coverage in your test suite.

You are right. Your argument applies to memory leaks as well as file
descriptor leaks.

Personally I've used a static analyzer with the purpose of finding file
descriptor leaks but not for memory leaks. I don't know why; maybe
because for file descriptor leaks there are fewer reports and thus
fewer false findings to eliminate? Or because we have valgrind for the
memory leaks but no experience with 'valgrind --track-fds'?

> Another point is: a library exit / cleanup call before exiting the
> application can easily free all reachable memory and by that disguise or
> hide internal memory leaks that lead to OOM in a long-running
> application (daemon or e.g. wget -r).
> In these cases it may be helpful to *not* free memory and not call exit
> library functions before exiting the application. Only then could
> valgrind show the memory hog (maybe the --xtree-memory option is for
> exactly that - I didn't investigate it yet).

It sounds like what you would need here is "heap profiling"
('valgrind --massif').

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]