Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'purpose.': 0.07; 'python': 0.09; 'subject:None': 0.09; 'subject:python': 0.11; 'result.': 0.15; 'combinations': 0.16; 'illustration': 0.16; 'received:169.254.3': 0.16; 'received:mgd.msft.net': 0.16; 'received:msft.net': 0.16; 'subject: \n ': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'version.': 0.17; 'memory': 0.18; 'to:name:python-list@python.org': 0.20; 'written': 0.20; 'os,': 0.22; 'subject:release': 0.22; 'example': 0.23; 'this:': 0.23; 'to:2**1': 0.23; 'seems': 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; '>>>>': 0.29; 'piece': 0.29; 'thinks': 0.29; 'received:169': 0.29; "skip:' 10": 0.30; 'header:Received:8': 0.30; 'expect': 0.31; 'not.': 0.32; 'achieving': 0.33; 'allocated': 0.33; 'instead,': 0.33; 'to:addr :python-list': 0.33; 'thanks': 0.34; 'received:bigfish.com': 0.35; 'but': 0.36; 'depends': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'operating': 0.36; 'does': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'received:10': 0.38; 'system.': 0.39; 'to:addr:python.org': 0.39; 'build': 0.39; 'subject:, ': 0.61; 'back': 0.62; 'received:10.9': 0.65; 'subject: ': 0.66; 'dies.': 0.84; 'received:10.9.14': 0.84; 'received:10.9.14.248': 0.84; 'received:65.55.88': 0.84; 'received:65.55.88.12': 0.84; 'subject:\t(': 0.84; 'subject:Set': 0.91; 'subject:del': 0.91 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zz148cIzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzzz2dh2a8h668h839h8e2h8e3h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh15d0h162dh1631h1758h18e1h1946h19b5h1ad9h1b0ahbe9i1155h) From: Wong Wah Meng-R32813 To: Steven D'Aprano , "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) Thread-Topic: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Thread-Index: AQHOGsPNVeasEGmgzUia3vP4E6GnC5iZxOCw Date: Thu, 7 Mar 2013 06:33:23 +0000 References: <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> <87zjyhhret.fsf@nautilus.nautilus> <5137d292$0$30001$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <5137d292$0$30001$c3e8da3$5496439d@news.astraweb.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.228.69.184] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: freescale.com 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362638941 news.xs4all.nl 6936 [2001:888:2000:d::a6]:48671 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40710 Python does not guarantee to return memory to the operating system.=20 Whether it does or not depends on the OS, but as a general rule, you should= expect that it will not. >>>> for i in range(100000L): > ... str=3Dstr+"%s"%(i,) You should never build large strings in that way. It risks being=20 horribly, horribly slow on some combinations of OS, Python implementation=20 and version. Instead, you should do this: items =3D ["%s" % i for i in range(100000)] s =3D ''.join(items) [] The example is written for illustration purpose. Thanks for pointing out= a better way of achieving the same result. Yes it seems so that the OS thi= nks the piece allocated to Python should not be taken back unless the proce= ss dies. :(