Python not giving free memory back to the os get's me in real problems ...

Charles Sanders C.delete_this.Sanders at BoM.GOv.AU
Wed Apr 25 21:34:52 EDT 2007


Grant Edwards wrote:
> Assuming the python interpreter free()s the memory, my
> understanding is that on Unixes the memory is returned to the
> pool used by malloc(), but is not returned to the OS since
> there isn't a practical way to ensure that the memory at the
> "end" of the data segment is not used.

http://www.dent.med.uni-muenchen.de/~wmglo/malloc-slides.html

 > Large chunks are allocated via mmap(). The threshold is set
 > through the environment variable MALLOC_MMAP_THRESHOLD_.
 > The maximum number of chunks allocated in this way is limited
 > through MALLOC_MMAP_MAX_.

	I think these large chunks are returned to the OS when
freed.

 > Trimming occurs when the size of the top chunk exceeds
 > MALLOC_TRIM_THRESHOLD_.

	I think this means that memory for small chunks
is returned to the OS if the free space at the top of the
heap exceeds the threshold.

> Asking on the gnu libc mailing list would probably provide a
> more authoritative answer.  I'd wager that they even know what
> other non-Gnu libc implementations do.

	Agreed, they would be authoritative for GNU libc.

Charles



More information about the Python-list mailing list