From: emmanuel.choquet@hp.com (Emmanuel Choquet)
Subject: Re: Returning memory to system after a free
Date: 28 Aug 2002 01:08:00 -0700 [thread overview]
Message-ID: <7aabdf42.0208280008.8ac9925@posting.google.com> (raw)
In-Reply-To: TxWa9.255789$2p2.10296658@bin4.nnrp.aus1.giganews.com
"
> "Jan Sundberg" <janne@nevdull.nu> wrote in message
> news:e7875f7.0208270237.4e0ba29e@posting.google.com...
> > Hi.
> >
> > I'm trying to return memory segments to kernel after a free.
> > This har been tested and verified by using the malloc tuning values
> > on both 4.0 and 5.1:
malloc has actually to do only with virtual memory, IE address space.
roughly, the process is the following, in the VM space of the process
:
if the malloc space asked is new - has never been asked - the Mach
kernel and Unix VM algorithm will map the space in your process -
free() will not unmap the space, Mach and Unix level, VSize of the
process will remain the same.
In a next malloc call, within the size of the first call, Mach kernel
and Unix memory allocation have nothing to do, the new space can be on
overlap with the former freed space, VM and Physical.
Now in the physical memory side, you first have 2 cases :
- 'normal' process, address space is created at malloc call, and
Zero-filled pages will be created at 1st access, making the RSS
growing. if you free, nothing happens, or at least nothing is
different compared to not freeing. RSS can remain the same, and Vsize
will obviously remain the same. To get back memory to free list -
shrinking the RSS-, the standard memory allocation algorithm applies :
possibily paging out if free list is under vm_page_free_min or swapped
out if free list under vm_page_free_optimal and no process thread has
been runnable for the last 20/30 seconds.
- Process attributes include locking page in memory -(Real time
option). In this case all physical pages are created at malloc call,
not at access time. The strange thing is that pages will not be paged
out, but process can be swapped out !
This behavior is *very* efficient for standard malloc usage, and
-trade off- very poor for huge mallocs, followed by free(). Long
process inactivity which can lead to long swapout time of useless
data. Paging out these inconsistent pages is painful as well.
Emmanuel
prev parent reply other threads:[~2002-08-28 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-27 10:37 Returning memory to system after a free Jan Sundberg
2002-08-28 2:26 ` Ian Cairns
2002-08-28 8:08 ` Emmanuel Choquet [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox