Apologies as after I have left the group for a while I have forgotten how not to post a question on top of another question. Very sorry and appreciate your replies.
I tried explicitly calling gc.collect() and didn't manage to see the memory footprint reduced. I probably haven't left the process idle long enough to see the internal garbage collection takes place but I will leave it idle for more than 8 hours and check again. Thanks! -----Original Message----- From: Python-list [mailto:python-list-bounces+wahmeng=freescale....@python.org] On Behalf Of Bryan Devaney Sent: Wednesday, March 06, 2013 6:25 PM To: python-list@python.org Cc: python-list@python.org Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) On Wednesday, March 6, 2013 10:11:12 AM UTC, Wong Wah Meng-R32813 wrote: > Hello there, > > > > I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box. > > > > I discovered following behavior whereby the python process doesn't seem to > release memory utilized even after a variable is set to None, and "deleted". > I use glance tool to monitor the memory utilized by this process. Obviously > after the for loop is executed, the memory used by this process has hiked to > a few MB. However, after "del" is executed to both I and str variables, the > memory of that process still stays at where it was. > > > > Any idea why? > > > > >>> for i in range(100000L): > > ... str=str+"%s"%(i,) > > ... > > >>> i=None > > >>> str=None > > >>> del i > > >>> del str Hi, I'm new here so I'm making mistakes too but I know they don't like it when you ask your question in someone else's question. that being said, to answer your question: Python uses a 'garbage collector'. When you delete something, all references are removed from the object in memory, the memory itself will not be freed until the next time the garbage collector runs. When that happens, all objects without references in memory are removed and the memory freed. If you wait a while you should see that memory free itself. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list