releasing memory to malloc

Gabriel Genellina gagsl-py at
Wed Sep 27 03:08:25 CEST 2006

At Tuesday 26/9/2006 21:34, 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).

Can you modify the C source? If you can, use the Python memory 
allocation functions PyMem_Malloc/PyMem_Realloc/PyMem_Free.

Gabriel Genellina
Softlab SRL 

Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!

More information about the Python-list mailing list