Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'none,': 0.05; 'executed': 0.07; 'python': 0.09; 'deletion': 0.09; 'handlers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:None': 0.09; 'terry': 0.09; 'variables,': 0.09; 'subject:python': 0.11; 'times,': 0.13; '"del"': 0.16; "compiler's": 0.16; 'executed,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'return,': 0.16; 'rewritten': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'obviously': 0.18; 'memory': 0.18; 'variable': 0.20; 'bit': 0.21; 'subject:release': 0.22; 'purposes': 0.23; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; "doesn't": 0.28; 'header:X -Complaints-To:1': 0.28; 'idea,': 0.29; 'str': 0.29; 'probably': 0.29; 'returned': 0.30; 'generally': 0.32; 'to:addr:python-list': 0.33; 'monitor': 0.33; 'built-in': 0.35; 'received:org': 0.36; 'tool': 0.36; 'but': 0.36; 'depends': 0.36; 'subject: (': 0.36; 'bad': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'behavior': 0.64; 'box.': 0.65; 'subject: ': 0.66; 'restore': 0.69; 'discovered': 0.83; '2.7.1': 0.84; 'received:fios.verizon.net': 0.84; 'utilized': 0.84; 'glance': 0.91; 'subject:Set': 0.91; 'subject:del': 0.91; 'whereby': 0.91; 'factors': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Date: Wed, 06 Mar 2013 05:59:57 -0500 References: <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> <87zjyhhret.fsf@nautilus.nautilus> <78E1273CA6E76A43BB8830A194FF709B0B12EB11@039-SN2MPN1-012.039d.mgd.msft.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <78E1273CA6E76A43BB8830A194FF709B0B12EB11@039-SN2MPN1-012.039d.mgd.msft.net> 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: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362567617 news.xs4all.nl 6977 [2001:888:2000:d::a6]:40880 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40627 On 3/6/2013 5:11 AM, 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. Whether memory freed by deleting an object is returned to and taken by the OS depends on the OS and other factors like like the size and layout of the freed memory, probably the history of memory use, and for CPython, the C compiler's malloc/free implementation. At various times, the Python memory handlers have been rewritten to encourage/facilitate memory return, but Python cannot control the process. > for i in range(100000L): > str=str+"%s"%(i,) > i=None; str=None # not necessary > del i; del str Reusing built-in names for unrelated purposes is generally a bad idea, although the final deletion does restore access to the builtin. -- Terry Jan Reedy