The workaround I've settled for uses the shelve module and calls
to gc.collect() to put a cap on the amount of memory the Python
allocator consumes. A bit more intrusive but it gets the job done.

Would a gc method that released memory to malloc be something
worth adding to Python? Or are there reasons why allowing this is
a bad idea?

Iker

[EMAIL PROTECTED] 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

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to