Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder1.xlned.com!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'memory.': 0.05; '(so': 0.07; 'chunk': 0.07; 'exit': 0.07; 'python': 0.09; 'exiting': 0.09; 'fork': 0.09; 'malloc': 0.09; 'objects.': 0.09; 'spawn': 0.09; 'subject:None': 0.09; 'subject:python': 0.11; 'sat,': 0.15; '(just': 0.16; 'allocates': 0.16; 'growing,': 0.16; 'libc': 0.16; 'mmap': 0.16; 'reliably': 0.16; 'wrote:': 0.17; 'memory': 0.18; 'to:name:python-list@python.org': 0.20; 'os,': 0.22; 'subject:release': 0.22; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'run': 0.28; 'continually': 0.29; 'url:mailman': 0.29; 'objects': 0.29; 'skip:& 10': 0.29; 'probably': 0.29; 'point': 0.31; 'url:python': 0.32; 'running': 0.32; 'url:listinfo': 0.32; 'allocated': 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'server': 0.35; 'needed': 0.35; 'returning': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'url:org': 0.36; 'modules': 0.36; "wasn't": 0.36; 'should': 0.36; 'too': 0.36; 'being': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'planning': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'short': 0.39; 'application': 0.40; 'url:mail': 0.40; 'your': 0.60; 'easy': 0.60; 'subject:, ': 0.61; 'more.': 0.62; 'back': 0.62; 'different': 0.63; 'more': 0.63; 'choose': 0.65; 'taking': 0.65; 'guaranteed': 0.76; '2013': 0.84; 'computation,': 0.84; 'footprint': 0.84; 'program.\xa0': 0.84; 'subject:Set': 0.91; 'subject:del': 0.91; 'whereby': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=PBWNe9mGOziNlYdRA3cVDx4etZjP8+jPdERCfcYp0os=; b=aKLT0X08JXWdzaWIy3LCoj3RpaxuqWDnknGmvF0qyQFGXQFatZsMIFk3H3FzqbB8E5 BKmPEMG7QZfnJkK/muE8utdZAes5dX+hvXKbRtkkdMcYx6Ow3IEC9P5IhjeOSDvnpaXW HBjbjEv3ThhagWrxsHf7BrpueUMYcyRYhUcYNCaKkJh8HeGjoVobnstfEh1fVxCxHfKB BTwa36IsQeIAwhU8F7E9vOLrZY5TAK8fx9tgcn/gIAHLaNy+Egz94k5FQom5PWrmzrf+ yoC3RmplgAbvTWVzj/etphggRQfdum3dJb1CTK39yLCSmgeEUcSs+DXm6a9lmTNCab3h UUwQ== MIME-Version: 1.0 X-Received: by 10.224.191.68 with SMTP id dl4mr9156986qab.85.1362841337202; Sat, 09 Mar 2013 07:02:17 -0800 (PST) In-Reply-To: <78E1273CA6E76A43BB8830A194FF709B0B157FC9@039-SN2MPN1-013.039d.mgd.msft.net> References: <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> <87zjyhhret.fsf@nautilus.nautilus> <5137d292$0$30001$c3e8da3$5496439d@news.astraweb.com> <78E1273CA6E76A43BB8830A194FF709B0B14D68C@039-SN2MPN1-013.039d.mgd.msft.net> <78E1273CA6E76A43BB8830A194FF709B0B153A71@039-SN2MPN1-013.039d.mgd.msft.net> <78E1273CA6E76A43BB8830A194FF709B0B157FC9@039-SN2MPN1-013.039d.mgd.msft.net> Date: Sat, 9 Mar 2013 23:02:17 +0800 Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) From: Isaac To To: "python-list@python.org" Content-Type: multipart/alternative; boundary=20cf3005dc38ca18e504d77f39a8 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: 92 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362841346 news.xs4all.nl 6888 [2001:888:2000:d::a6]:46041 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40948 --20cf3005dc38ca18e504d77f39a8 Content-Type: text/plain; charset=ISO-8859-1 In general, it is hard for any process to return the memory the OS allocate to it back to the OS, short of exiting the whole process. The only case that this works reliably is when the process allocates a chunk of memory by mmap (which is chosen by libc if it malloc or calloc a large chunk of memory), and that whole chunk is not needed any more. In that case the process can munmap it. Evidently you are not see that in your program. What you allocate might be too small (so libc choose to allocate it using another system call "sbrk"), or that the allocated memory also hold other objects not freed. If you want to reduce the footprint of a long running program that periodically allocates a large chunk of memory, the "easiest" solution is to fork a different process to achieve the computations that needs the memory. That way, you can exit the process after you complete the computation, and at that point all memory allocated to it is guaranteed to be freed to the OS. Modules like multiprocessing probably make the idea sufficiently easy to implement. On Sat, Mar 9, 2013 at 4:07 PM, Wong Wah Meng-R32813 wrote: > > > If the memory usage is continually growing, you have something > else that is a problem -- something is holding onto objects. Even if Python > is not returning memory to the OS, it should be reusing the memory it has > if objects are being freed. > -- > [] Yes I have verified my python application is reusing the memory (just > that it doesn't reduce once it has grown) and my python process doesn't > have any issue to run even though it is seen taking up more than 2G in > footprint. My problem is capacity planning on the server whereby since my > python process doesn't release memory back to the OS, the OS wasn't able to > allocate memory when a new process is spawn off. > > -- > http://mail.python.org/mailman/listinfo/python-list > --20cf3005dc38ca18e504d77f39a8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
In general, it is hard for any process to return= the memory the OS allocate to it back to the OS, short of exiting the whol= e process.=A0 The only case that this works reliably is when the process al= locates a chunk of memory by mmap (which is chosen by libc if it malloc or = calloc a large chunk of memory), and that whole chunk is not needed any mor= e.=A0 In that case the process can munmap it.=A0 Evidently you are not see = that in your program.=A0 What you allocate might be too small (so libc choo= se to allocate it using another system call "sbrk"), or that the = allocated memory also hold other objects not freed.

If you want to reduce the footprint of a long running program tha= t periodically allocates a large chunk of memory, the "easiest" s= olution is to fork a different process to achieve the computations that nee= ds the memory.=A0 That way, you can exit the process after you complete the= computation, and at that point all memory allocated to it is guaranteed to= be freed to the OS.

Modules like multiprocessing probably make the idea sufficiently = easy to implement.


On Sat, Mar 9, 2013 at 4:07 PM, Wong Wah Meng-R32813 <= r32813@freescale.com> wrote:


=A0 =A0 =A0 =A0 If the memory usage is continually growing, you have someth= ing else that is a problem -- something is holding onto objects. Even if Py= thon is not returning memory to the OS, it should be reusing the memory it = has if objects are being freed.
--
[] Yes I have verified my python application is reusing the memory (j= ust that it doesn't reduce once it has grown) and my python process doe= sn't have any issue to run even though it is seen taking up more than 2= G in footprint. My problem is capacity planning on the server whereby since= my python process doesn't release memory back to the OS, the OS wasn&#= 39;t able to allocate memory when a new process is spawn off.

--
http://mail.python.org/mailman/listinfo/python-list

--20cf3005dc38ca18e504d77f39a8--