lua-users home
lua-l archive

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

On Wed, 2006-11-22 at 16:40 -0500, Javier Guerra wrote:
> On Wednesday 22 November 2006 4:32 pm, Nick Nugent wrote:
> > case, however, in contrast to the first, inspecting the size of the
> > interpreter's process in the host operating system shows that very
> > little of the total memory allocated by this script is ever freed.
> in Linux (like any Unix, AFAIK), it's very rare for a process to return memory 
> to the OS; any free()'d memory is returned to an in-process free list.  the 
> process size (as reported by /proc, ps, top, and friends) is roughly the max 
> size it has reached.

Additionally, the reason for this is that the memory is allocated
logically in a flat space, so if you have one block still allocated
right at the end, but megabytes of free memory before it, this can't
easily be returned to the OS if the memory was allocated by brk() (which
extends the process's memory.)

What happens may be very different if the memory was allocated via
mmap(), however.