Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40633

Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'none,': 0.05; 'executed': 0.07; 'python': 0.09; 'counting': 0.09; 'garbage': 0.09; 'referenced': 0.09; 'references,': 0.09; 'runtime': 0.09; 'subject:None': 0.09; 'variables,': 0.09; 'itself.': 0.11; 'subject:python': 0.11; 'library': 0.15; '"del"': 0.16; 'bryan': 0.16; 'chunks.': 0.16; 'executed,': 0.16; 'hierarchy': 0.16; 'processes.': 0.16; 'relevant,': 0.16; 'runs.': 0.16; 'subject: \n ': 0.16; 'tuple,': 0.16; 'utc,': 0.16; 'zero,': 0.16; 'wrote:': 0.17; 'pieces': 0.17; 'obviously': 0.18; 'memory': 0.18; 'variable': 0.20; 'bit': 0.21; 'os,': 0.22; 'subject:release': 0.22; 'wednesday,': 0.22; 'elements': 0.23; 'references': 0.23; 'so.': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; 'am,': 0.27; 'separate': 0.27; 'object,': 0.27; "doesn't": 0.28; 'cycles': 0.29; 'piece': 0.29; 'str': 0.29; 'case,': 0.29; 'no,': 0.29; 'objects': 0.29; 'function.': 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; 'monitor': 0.33; 'another': 0.33; 'done': 0.34; 'list': 0.35; 'bigger': 0.35; 'there': 0.35; 'next': 0.35; 'list.': 0.35; 'created': 0.36; 'tool': 0.36; 'should': 0.36; 'subject: (': 0.36; 'turn': 0.36; 'itself': 0.37; 'does': 0.37; 'two': 0.37; 'uses': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'delete': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'received:192': 0.39; 'little': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'subject:, ': 0.61; 'monitoring': 0.61; 'free': 0.61; 'deals': 0.62; 'behavior': 0.64; 'other.': 0.64; 'choose': 0.65; 'box.': 0.65; 'sound': 0.65; 'subject: ': 0.66; 'received:74.208': 0.71; 'counts': 0.81; 'discovered': 0.83; '2.7.1': 0.84; '2013': 0.84; 'actually,': 0.84; 'parcels': 0.84; 'utilized': 0.84; 'glance': 0.91; 'subject:Set': 0.91; 'subject:del': 0.91; 'whereby': 0.91
Date Wed, 06 Mar 2013 08:18:00 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version 1.0
To 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)
References <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> <87zjyhhret.fsf@nautilus.nautilus> <mailman.2934.1362564689.2939.python-list@python.org> <18272cff-cfb0-4bd3-8f5d-3b4641ba828e@googlegroups.com>
In-Reply-To <18272cff-cfb0-4bd3-8f5d-3b4641ba828e@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:guZyzNRqva4yT7b4Qk8AJSQuMmIz/ZCiLnlcWlLH3RI Zpzus/sYS7f94dILYMXeIBUJF1gy+sSxkcPUrlLCRxhAtbRViX 0FzlW/rW9OfAEzq2meG527SOKMmrShAoyO31m1QXG1WfIzRKdU 1W763SskR+COhlHHuEKekkx1b62+dcGo5L/z4oSE2zQJFVMMrv La4fHXTB92W6ykDLydPHEABUgUCFPMiaIeoW5ruyYAgDC18aUP Q0vOlWhv5VyfHwMpJUg+2byv52ZmMLoYTsbLPnTjAGwkjODHsl XmEDB05/hHs62xvmEht0SozrnN9DKHC3YkJUlDl/ZzYO3lBfA= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2943.1362575899.2939.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362575899 news.xs4all.nl 6950 [2001:888:2000:d::a6]:44948
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40633

Show key headers only | View raw


On 03/06/2013 05:25 AM, Bryan Devaney wrote:
> 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.
>>
>>   <SNIP>
>>
>
> 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.
>

Actually, no.  The problem with monitoring memory usage from outside the 
process is that memory "ownership" is hierarchical, and each hierarchy 
deals in bigger chunks.  So when the CPython runtime calls free() on a 
particular piece of memory, the C runtime may or may not actually 
release the memory for use by other processes.  Since the C runtime 
grabs big pieces from the OS, and parcels out little pieces to CPython, 
a particular big piece can only be freed if ALL the little pieces are 
free.  And even then, it may or may not choose to do so.

Completely separate from that are the two mechanisms that CPython uses 
to free its pieces.  It does reference counting, and it does garbage 
collecting. In this case, only the reference counting is relevant, as 
when it's done there's no garbage left to collect.  When an object is no 
longer referenced by anything, its count will be zero, and it will be 
freed by calling the C library function.  GC is only interesting when 
there are cycles in the references, such as when a list contains as one 
of its elements a tuple, which in turn contains the original list. 
Sound silly?  No, it's quite common once complex objects are created 
which reference each other.  The counts don't go to zero, and the 
objects wait for garbage collection.

OP:  There's no need to set to None and also to del the name.  Since 
there's only one None object, keeping another named reference to that 
object has very little cost.



-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 23:45 -0800
  Re: sync databse table based on current directory data without losign previous values Lele Gaifax <lele@metapensiero.it> - 2013-03-06 09:19 +0100
    Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 00:57 -0800
      Re: sync databse table based on current directory data without losign previous values Lele Gaifax <lele@metapensiero.it> - 2013-03-06 10:24 +0100
        Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 01:41 -0800
          Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 01:43 -0800
            Re: sync databse table based on current directory data without losign previous values Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-06 02:15 -0800
            Re: sync databse table based on current directory data without losign previous values Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-06 02:15 -0800
          Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 01:43 -0800
          Re: sync databse table based on current directory data without losign previous values Lele Gaifax <lele@metapensiero.it> - 2013-03-06 11:27 +0100
          Re: sync databse table based on current directory data without losign previous values Dave Angel <davea@davea.name> - 2013-03-06 08:31 -0500
          Re: sync databse table based on current directory data without losign previous values Lele Gaifax <lele@metapensiero.it> - 2013-03-06 15:16 +0100
        Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 01:41 -0800
    Re: sync databse table based on current directory data without losign previous values Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 00:57 -0800
  Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-06 10:11 +0000
    Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-06 02:25 -0800
      RE: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-06 12:31 +0000
      Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Dave Angel <davea@davea.name> - 2013-03-06 08:18 -0500
      Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Dave Angel <davea@davea.name> - 2013-03-06 08:25 -0500
    Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-06 02:25 -0800
    Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-06 23:34 +0000
      RE: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-07 06:33 +0000
      Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Chris Angelico <rosuav@gmail.com> - 2013-03-07 18:19 +1100
      RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-08 09:08 +0000
      Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-03-08 19:40 -0500
      RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-09 08:07 +0000
        Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Grant Edwards <invalid@invalid.invalid> - 2013-03-09 19:18 +0000
          Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Roy Smith <roy@panix.com> - 2013-03-09 15:04 -0500
            Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Grant Edwards <invalid@invalid.invalid> - 2013-03-09 20:35 +0000
              Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Roy Smith <roy@panix.com> - 2013-03-09 16:44 -0500
                Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Grant Edwards <invalid@invalid.invalid> - 2013-03-11 14:27 +0000
      Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Dave Angel <davea@davea.name> - 2013-03-09 06:02 -0500
      Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Isaac To <isaac.to@gmail.com> - 2013-03-09 23:02 +0800
  Re: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Terry Reedy <tjreedy@udel.edu> - 2013-03-06 05:59 -0500
  Re: sync databse table based on current directory data without losign previous values Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-06 11:52 +0000
  RE: Set x to  to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) Wong Wah Meng-R32813 <r32813@freescale.com> - 2013-03-06 12:36 +0000
  Re: sync databse table based on current directory data without losign previous values Chris Angelico <rosuav@gmail.com> - 2013-03-07 00:40 +1100
  Re: sync databse table based on current directory data without losign previous values "Michael Ross" <gmx@ross.cx> - 2013-03-06 15:04 +0100
    Re: sync databse table based on current directory data without losign previous values nagia.retsina@gmail.com - 2013-03-06 08:09 -0800
    Re: sync databse table based on current directory data without losign previous values nagia.retsina@gmail.com - 2013-03-06 08:09 -0800

csiph-web