releasing memory to malloc

iker.arizmendi at iker.arizmendi at
Fri Sep 29 02:46:50 CEST 2006

The workaround I went with made use of the shelve module and
calls to gc.collect() to cap the memory consumed by the Python
allocator. It was a bit intrusive but it got the job done.

Would a method in the gc module that released memory to malloc
be something that could get added to Python? Or are there some
reasons why allowing that would be a bad idea?


This may be a repeat of an earlier message - it seems that
google groups may have discarded my earlier post.

iker.arizmendi at wrote:
> Is there any way to get Python to release memory back to the
> C allocator? I'm currently running a script that goes through
> the following steps:
> 1) Creates a very large number of Python objects to produce
> a relatively small data structure that sits in a C extension.
> The Python objects consume quite a bit of memory.
> 2) Releases all the Python objects.
> 3) Invokes a function of said C extension for further
> processing. This step needs as much memory as possible.
> I'd like step 2 to return memory to the C allocator so that it
> is available to the extension in step 3 (which uses malloc).
> Regards,
> Iker Arizmendi

More information about the Python-list mailing list