releasing memory to malloc

MrJean1 MrJean1 at gmail.com
Thu Oct 5 12:22:06 CEST 2006


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

  <http://docs.python.org/whatsnew/ports.html>.

/Jean Brouwers



iker.arizmendi at gmail.com wrote:
> 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?
>
> Regards,
> Iker
>
> P.S.
> This may be a repeat of an earlier message - it seems that
> google groups may have discarded my earlier post.
>
>
> iker.arizmendi at gmail.com 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