All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Teo <eugene.teo@eugeneteo.net>
To: Rik van Riel <riel@redhat.com>
Cc: Vinay I K <abcxyz1@lycos.com>, Linux-MM@kvack.org
Subject: Re: Linux free issue
Date: Sun, 20 Jul 2003 10:27:43 +0800	[thread overview]
Message-ID: <20030720022743.GD16983@eugeneteo.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0307191037530.26759-100000@chimarrao.boston.redhat.com>

<quote sender="Rik van Riel">
> On Sat, 19 Jul 2003, Vinay I K wrote:
> 
> > http://mail.nl.linux.org/linux-mm/1998-08/msg00028.html
> > 
> > I am a bit confused. When we call free in Linux, is the memory not given
> > back to the system(just cached)? What is the state of the issue in the
> > latest Linux Kernel?
> 
> The issue is not in the Linux kernel at all, but in glibc.
> It is the C library that has (after careful measuring and
> optimising) made the decision to not call the system call
> to free memory but instead keep it for later use.

I agree with Riel. It has nothing to do with the kernel,
but the implementation of the dynamic memory allocator
in the userspace C library.

The actual implementation might differ a little but the
general idea is that whenever you do a free, it deallocates
the region of memory by storing this "freed" space to a free
list. You will notice that the heap offset is not decreased
by using the sbrk syscall. The next time you call malloc,
it will search through the free list, and if a space matches,
that spaces will be used to your program. Otherwise, it will
increase the heap, allocate a region of memory you specified 
for your program instead.

Eugene

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  reply	other threads:[~2003-07-20  2:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-19 13:34 Linux free issue Vinay I K
2003-07-19 14:39 ` Rik van Riel
2003-07-20  2:27   ` Eugene Teo [this message]
2003-07-19 13:35 Vinay I K

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=20030720022743.GD16983@eugeneteo.net \
    --to=eugene.teo@eugeneteo.net \
    --cc=Linux-MM@kvack.org \
    --cc=abcxyz1@lycos.com \
    --cc=riel@redhat.com \
    /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.