All of lore.kernel.org
 help / color / mirror / Atom feed
From: jw schultz <jw@pegasys.ws>
To: linux-kernel@vger.kernel.org
Cc: Aleksandar Kacanski <kacanski@yahoo.com>
Subject: Re: Memory leak
Date: Mon, 26 Aug 2002 20:43:12 -0700	[thread overview]
Message-ID: <20020827034312.GA5196@pegasys.ws> (raw)
In-Reply-To: <Pine.LNX.3.95.1020826152100.6296B-100000@chaos.analogic.com>

On Mon, Aug 26, 2002 at 03:29:17PM -0400, 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.

brk() isn't the only way applications get memory.  A
commonly used method of getting process memory is to mmap()
anonymous regions.  Some implementations of malloc() will
use mmap() for larger allocations.  If you use realloc() a
lot this can be particularly useful.

Releasing memory that has been allocated via brk() is
dependent on allocation order so it is seldom done.
Realloc() and co. used poorly can produce lots of
fragmentation exacerbating things.  Allocations done via
mmap() tend to be independent of one another so they can
released more readily.

If an application or library is using mmap() just watching
brk won't do much good.  Actually detecting leakage is very
difficult especially from outside the code.  It requires
tracking the modifications of all the pointers to allocated
memory.

The thing to keep in mind for the common case is that
applications that leak memory will release it on exit.
Most of the time any sizable amount of application memory is 
in disuse it will be in sizable chunks so under memory
pressure will be paged out until exit so will have minimal
impact on the system.

Having said all that i'll now echo Linus et al and tell you
that you want the system to use all of your memory.  Unused
memory is wasted memory and wasted money.  That is why
otherwise free memory is used as cache and disused memory
will be paged out so that it too can be used as cache to
speed up the system as a whole.

And much thanks to all the good, and heartless bastard,
developers who have and continue to work on improving the
paging algorithms and VM system as a whole.

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw@pegasys.ws

		Remember Cernan and Schmitt

  parent reply	other threads:[~2002-08-27  3:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-26 19:01 Memory leak Aleksandar Kacanski
2002-08-26 19:29 ` Richard B. Johnson
2002-08-26 19:44   ` george anzinger
2002-08-26 20:05     ` Richard B. Johnson
     [not found]     ` <Pine.LNX.3.95.1020826155614.6481A-100000@chaos.analogic.co m>
2002-08-27  5:44       ` Mike Galbraith
2002-08-27  3:43   ` jw schultz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-01-19  5:14 [PATCH v26 2/2] status: add status.compareBranches config for multiple branch comparisons Jeff King
2026-01-20  9:49 ` Memory leak Harald Nordgren
2026-01-20 13:22   ` Harald Nordgren
2026-01-20 21:42     ` Junio C Hamano
2026-01-21 18:47       ` Junio C Hamano
2026-01-21 20:49         ` Jeff King
2026-01-22 15:03         ` Harald Nordgren
2026-01-22 18:19           ` Junio C Hamano
2008-04-09 13:54 hinko.kocevar
2003-03-12 19:50 Memory Leak Aman
2003-03-12 20:29 ` Matt Porter
2003-03-09 16:46 Memory leak matsunaga
2003-03-09 17:37 ` Charles Manning
2003-03-09 19:10 ` Thomas Gleixner
2003-03-09 23:10   ` matsunaga
2003-03-10 14:53     ` Thomas Gleixner
2003-03-10 14:14       ` David Woodhouse
2003-03-10 15:48         ` matsunaga
2003-03-10 16:02           ` David Woodhouse
2003-03-10 16:26             ` matsunaga
2003-03-10 17:04               ` David Woodhouse
2003-03-11 15:52                 ` matsunaga
2003-03-11 18:39                   ` Thomas Gleixner
2003-03-10 15:36       ` matsunaga
2003-03-11 17:50 ` David Woodhouse
2002-06-20 15:06 diekema_jon
2002-06-20  7:52 Skip Gaede
2002-06-22  2:22 ` Skip Gaede
2002-06-20  2:24 Skip Gaede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020827034312.GA5196@pegasys.ws \
    --to=jw@pegasys.ws \
    --cc=kacanski@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.