Python 2.6 still not giving memory back to the OS...
rylesny at gmail.com
Sun Aug 16 23:10:25 CEST 2009
On Aug 15, 7:55 am, Chris Withers <ch... at simplistix.co.uk> wrote:
> Hi All,
> I thought this was fixed back in Python 2.5, but I guess not?
> So, I'm playing in an interactive session:
> >>> from xlrd import open_workbook
> >>> b = open_workbook('some.xls',pickleable=0,formatting_info=1)
> At this point, top shows the process usage for python to be about 500Mb.
> That's okay, I'd expect that, b is big ;-)
> >>> del b
> However, it still does now, maybe the garbage collector needs a kick?
> >>> import gc
> >>> gc.collect()
> Nope, still 500Mb. What gives? How can I make Python give the memory its
> no longer using back to the OS?
> Okay, so maybe this is something to do with it being an interactive
> session? So I wrote this script:
> from xlrd import open_workbook
> import gc
> b = open_workbook('some.xls',pickleable=0,formatting_info=1)
> print 'opened'
> del b
> print 'deleted'
> print 'gc'
> The raw inputs are there so I can check the memory usage in top.
> Even after the gc, Python still hasn't given the memory back to the OS :-(
> What am I doing wrong?
> Simplistix - Content Management, Batch Processing & Python Consulting
Repeat the 'b = open_workbook ...' line in the interpreter several
times and track the memory usage after each execution. I noticed this
behavior on linux, but saw that after repeating it a few times memory
usage finally stop going up. Probably just the behavior of the
More information about the Python-list