Reclaiming (lots of) memory

Thomas Rast foo.bar at freesurf.ch.invalid
Mon Oct 4 16:09:27 EDT 2004


Nick Craig-Wood <nick at craig-wood.com> writes:

> mmap("/dev/zero") behaves in pretty much the same way (ie it shrinks
> and grows), except for large allocation (>4k I think) the allocation
> is done in its own mmap() area.  This means that when it is freed it
> completely disappears.

Ok.  That explains why e.g.

>>> l = [0] * 10000000  # 10 million
>>> del l

frees the memory used for l, as expected.

> Thats a neat idea.  You could also build a dbm in the forked
> process.

I've implemented it that way now.  Using a pipe to transfer the data
to the dbm appears to essentially double the I/O overhead and is very
inefficient.

> >  is there an easier way to get my RAM back?
> 
> I don't think so, but hopefully an expert who knows something about
> how python allocates its objects will speak up now!

Well, can't blame Python if you'd need black magic even in C ;-)

Thanks for the explanations!

Thomas

-- 
If you want to reply by mail, substitute my first and last name for
'foo' and 'bar', respectively, and remove '.invalid'.



More information about the Python-list mailing list