Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'none,': 0.05; 'executed': 0.07; 'python': 0.09; 'garbage': 0.09; 'subject:None': 0.09; 'to:addr:comp.lang.python': 0.09; 'variables,': 0.09; 'cc:addr :python-list': 0.10; 'itself.': 0.11; 'subject:python': 0.11; '"del"': 0.16; 'executed,': 0.16; 'runs.': 0.16; 'subject: \n ': 0.16; 'utc,': 0.16; 'wrote:': 0.17; 'obviously': 0.18; '>>>': 0.18; 'memory': 0.18; 'variable': 0.20; 'question.': 0.20; 'bit': 0.21; 'subject:release': 0.22; 'wednesday,': 0.22; 'cc:2**0': 0.23; 'references': 0.23; 'idea': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'question': 0.27; "doesn't": 0.28; 'question:': 0.29; 'str': 0.29; 'objects': 0.29; "i'm": 0.29; 'monitor': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'said,': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'tool': 0.36; 'but': 0.36; 'should': 0.36; 'too': 0.36; 'subject: (': 0.36; 'itself': 0.37; 'uses': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'delete': 0.38; 'there,': 0.38; 'release': 0.39; 'where': 0.40; 'your': 0.60; 'subject:, ': 0.61; 'free': 0.61; 'behavior': 0.64; 'making': 0.64; 'here': 0.65; 'box.': 0.65; 'subject: ': 0.66; 'discovered': 0.83; '2.7.1': 0.84; '2013': 0.84; "else's": 0.84; 'utilized': 0.84; 'why?': 0.84; 'glance': 0.91; 'subject:Set': 0.91; 'subject:del': 0.91; 'whereby': 0.91; 'mistakes': 0.95 X-Received: by 10.49.63.164 with SMTP id h4mr2818747qes.39.1362565522284; Wed, 06 Mar 2013 02:25:22 -0800 (PST) Newsgroups: comp.lang.python Date: Wed, 6 Mar 2013 02:25:22 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=15.203.169.106; posting-account=1a8NwAoAAAB7s3B2HLVQDLqOtVhlP4u9 References: <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> <87zjyhhret.fsf@nautilus.nautilus> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 15.203.169.106 MIME-Version: 1.0 Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) From: Bryan Devaney To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362568281 news.xs4all.nl 6888 [2001:888:2000:d::a6]:48724 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40628 On Wednesday, March 6, 2013 10:11:12 AM UTC, Wong Wah Meng-R32813 wrote: > Hello there, >=20 >=20 >=20 > I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box.=20 >=20 >=20 >=20 > I discovered following behavior whereby the python process doesn't seem t= o release memory utilized even after a variable is set to None, and "delete= d". I use glance tool to monitor the memory utilized by this process. Obvio= usly after the for loop is executed, the memory used by this process has hi= ked to a few MB. However, after "del" is executed to both I and str variabl= es, the memory of that process still stays at where it was.=20 >=20 >=20 >=20 > Any idea why? >=20 >=20 >=20 > >>> for i in range(100000L): >=20 > ... str=3Dstr+"%s"%(i,)=20 >=20 > ...=20 >=20 > >>> i=3DNone >=20 > >>> str=3DNone >=20 > >>> del i >=20 > >>> del str Hi, I'm new here so I'm making mistakes too but I know they don't like it w= hen you ask your question in someone else's question.=20 that being said, to answer your question: Python uses a 'garbage collector'. When you delete something, all reference= s are removed from the object in memory, the memory itself will not be free= d until the next time the garbage collector runs. When that happens, all ob= jects without references in memory are removed and the memory freed. If yo= u wait a while you should see that memory free itself.