Re: releasing memory to malloc

2006-10-05 Thread MrJean1
The memory manager in the latest Python release 2.5 does return freed memory to the underlying system, if possible. For more details, see the 5th bullet on this page . /Jean Brouwers [EMAIL PROTECTED] wrote: > The workaround I went with made use of

Re: releasing memory to malloc

2006-09-28 Thread iker . arizmendi
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

Re: releasing memory to malloc

2006-09-28 Thread iker . arizmendi
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 rea

Re: releasing memory to malloc

2006-09-28 Thread Paul Rubin
Bryan Olson <[EMAIL PROTECTED]> writes: > I think I see what you're doing, but fork() after step 1 will > create a child process with the same memory allocated. > > I think it would make more sense to do step 1 in a subprocess. > Use the subprocess module or one of the older popen()s to create > a

Re: releasing memory to malloc

2006-09-28 Thread Bryan Olson
Paul Rubin 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

Re: releasing memory to malloc

2006-09-26 Thread Paul Rubin
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 Pyth

Re: releasing memory to malloc

2006-09-26 Thread iker . arizmendi
I happen to have the code for the C library in question, but I don't think this is the way to go in general. If there's a way to get Python to give memory back to the C allocator I can avoid touching the library at all. Regards, Iker John Machin wrote: > [EMAIL PROTECTED] wrote: > > I can, but t

Re: releasing memory to malloc

2006-09-26 Thread Gabriel Genellina
At Tuesday 26/9/2006 22:17, [EMAIL PROTECTED] wrote: I can, but the extension is only a thin wrapper around a general purpose C library which is also used independently of Python. If you can recompile a specific version for using with Python, you can play with a few macros like #ifdef USE_P

Re: releasing memory to malloc

2006-09-26 Thread John Machin
[EMAIL PROTECTED] wrote: > I can, but the extension is only a thin wrapper around a general > purpose C library which is also used independently of Python. > So change the library to use xmalloc etc and add something like this to the .h file: #ifdef PYMEM #define xmalloc PyMem_Malloc etc #else #

Re: releasing memory to malloc

2006-09-26 Thread iker . arizmendi
I can, but the extension is only a thin wrapper around a general purpose C library which is also used independently of Python. Iker Gabriel Genellina wrote: > Can you modify the C source? If you can, use the Python memory > allocation functions PyMem_Malloc/PyMem_Realloc/PyMem_Free. > > > > Gabr

Re: releasing memory to malloc

2006-09-26 Thread Gabriel Genellina
At Tuesday 26/9/2006 21:34, [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

Re: releasing memory to malloc

2006-09-26 Thread John Machin
[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 extens

releasing memory to malloc

2006-09-26 Thread iker . arizmendi
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