On Aug 15, 7:55 am, Chris Withers <ch...@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() > 702614 > > 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' > raw_input() > del b > print 'deleted' > raw_input() > gc.collect() > print 'gc' > raw_input() > > 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? > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > -http://www.simplistix.co.uk
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 allocator. -- http://mail.python.org/mailman/listinfo/python-list