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

Re: Potential memory leaks reported by Valgrind against some frequently used commands



01.03.2011 14:56, Aron Xu wrote:
> On Tue, Mar 1, 2011 at 19:54, Olaf van der Spek <olafvdspek@gmail.com> wrote:
>> 2011/3/1 ximalaya <ims3g@126.com>:
>>> I notice that, valgrind reports memory leaks against some frequently used
>>> commands on Debian 6.0, 5.0.7 and 4.0. These commands include netstat, ps
>>> -ef, ls -latr, top, etc.
>>
>> For short-running processes that's generally not a problem.

> 
> It would be good if we fix them, :)


There are at least two kinds of "memory leaks" which may be present
and reported here.  One is a single memory buffer allocated (and may
be reallocated) for some one-time task and not freed.  And another
may be a missing free for every object a program iterates - like
in case of ls, a memleak of an object for every file it lists.

First kinds of memory "leaks" are definitely _not_ worth to fix,
because if we'll exit right away anyway, kernel will free all our
memory in one go after process termination, and by using free()
we just wating CPU time and gains nothing at all.

But second kind of leaks is definitely worth to fix, for obvious
reason: tools like ls(1) should not grow their memory without
bounds.

But I suspect there are only kind-1 "leaks" you found, at least
the ones which are reported are all of this sort.

Thanks!

/mjt


Reply to: