lkml.org 
[lkml]   [2002]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Memory leak
On Mon, 26 Aug 2002, george anzinger wrote:

> "Richard B. Johnson" wrote:
> >
> > On Mon, 26 Aug 2002, Aleksandar Kacanski wrote:
> >
> > > Hello,
> > > I am running 2.4.18-3 version of the kernel on smp dual
> > > processor and 1GB of RAM. My memory usage is increasing and
> > > I can't find what exactly is eating memory. Top and proc
> > > are reporting increases, but I would like to know of a
> > > better way of tracing usage of memory and possible leak in
> > > application(s).
> > >
> > > Please reply to kacanski@yahoo.com
> > > thanks Sasha
> > >
> > >
> >
> > Applications that use malloc() and friends, get more memory from
> > the kernel by resetting the break address. It's called "morecore()".
> > You can put a procedure, perhaps off SIGALRM, that periodically
> > checks the break address and writes it to a log. Applications
> > that end up with an ever-increasing break address have memory
> > leaks. Note that the break address is almost never set back.
> > This is not an error; malloc() assumes that if you used a lot
> > of memory once, you'll probably use it again. Check out sbrk()
> > and brk() in the man pages.
>
> But this all comes back when the application ends. You
> should be able to see the memory reappear when the app
> terminates.
>

Not by looking at /proc/meminfo. The fact that Linux redistributes
buffers, etc., during normal operation has often been misconceived
as a memory leak. Linux will try to use all available memory. This
is because unused memory is wasted memory. When Linux first starts
up, there is little to do, and very little history, so it hasn't
gotten a chance to use much memory. If you run a few apps, compile
the kernel, etc., you get to use all the memory. Then when the
system is quiescent, often persons look at /proc/meminfo, note that
a lot of memory is being used, and declare that there must be some
kind of memory leak.

There just might be some kind of memory leak, but, you can't tell
it from looking at /proc/meminfo. You would need to instrument each
procedure that allocates memory and verify that all execution paths,
including exceptions, result in that memory being freed. This would
be a good project for one of the college students that is looking
to get his/her hands dirty. It's a lot more useful than 'inventing'
some new file-system that never gets used, etc.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
The US military has given us many words, FUBAR, SNAFU, now ENRON.
Yes, top management were graduates of West Point and Annapolis.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:28    [W:0.072 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site