[Numpy-discussion] python memory use

Robin robince@gmail....
Sat May 3 05:59:30 CDT 2008


Hi,

I am starting to push the limits of the available memory and I'd like
to understand a bit better how Python handles memory...

If I try to allocate something too big for the available memory I
often get a MemoryError exception. However, in other situations,
Python memory use continues to grow until the machine falls over. I
was hoping to understand the difference between those cases. From what
I've read Python never returns memory to the OS (is this right?) so
the second case, python is holding on to memory that it isn't really
using (for objects that have been destroyed). I guess my question is
why doesn't it reuse the memory freed from object deletions instead of
requesting more - and even then when requesting more, why does it
continue until the machine falls over and not cause a MemoryError?

While investigating this I found this script:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511474
which does wonders for my code. I was wondering if this function
should be included in Numpy as it seems to provide an important
feature, or perhaps an entry on the wiki (in Cookbook section?)

Thanks,

Robin


More information about the Numpy-discussion mailing list