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


Groups > comp.lang.python > #48008

Re: Debugging memory leaks

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'debugging': 0.07; 'correct,': 0.09; 'pointers': 0.09; 'references,': 0.09; 'python': 0.11; 'useful,': 0.14; '"should"': 0.16; 'buggy': 0.16; 'cleaned': 0.16; 'determining': 0.16; 'leaks': 0.16; 'pointers,': 0.16; 'received:74.208.4.195': 0.16; 'scope.': 0.16; 'why,': 0.16; 'zero,': 0.16; 'zero.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'mechanism': 0.19; 'seems': 0.21; 'code,': 0.22; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'circular': 0.24; "shouldn't": 0.24; 'why.': 0.24; "haven't": 0.24; "i've": 0.25; 'references': 0.26; 'post': 0.26; 'header:In- Reply-To:1': 0.27; 'code': 0.31; 'figure': 0.32; 'up.': 0.33; 'maybe': 0.34; "can't": 0.35; 'created': 0.35; 'objects': 0.35; 'but': 0.35; 'method': 0.36; 'thanks': 0.36; 'should': 0.36; 'being': 0.38; 'represent': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'gone': 0.61; "you're": 0.61; 'hang': 0.67; 'periodically': 0.68; 'received:74.208': 0.68; 'fragment': 0.84; 'leak': 0.84; 'leak.': 0.84; 'response,': 0.91; 'luck': 0.93
Date Thu, 13 Jun 2013 14:44:38 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6
MIME-Version 1.0
To python-list@python.org
Subject Re: Debugging memory leaks
References <09917103-b35e-4728-8fea-bcb4ce2bd1af@googlegroups.com> <ddaedafc-ed0c-45e1-a9bf-146aaff88d16@googlegroups.com>
In-Reply-To <ddaedafc-ed0c-45e1-a9bf-146aaff88d16@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:/hziIW198jDUIT5eaoIEVFjbcWgDiEcFRDQ2g6fKtUp wiHkEsKoYy20nBde0MkvuAkfToO+bnZ9ysbX96UM/aToGL6hSh wNiBWMaiOFmAg5k0MWmVOwZLO35Ia3G7t7hB1GLf7cN9tCHDU2 g1+gLjCJL8ate/j3oeA4sfqf9P/vt4bdw8C7+aa/2IpSk8iFm6 KpjaAVpIt2GnZ13uRYt8dR0U33Gm0aMnEp+y9PAXpumVMfhjKJ OfYmUen2WEZg1QaTsMDyMjkn+1nKk7HQAMb40ToaJBq3T/iCnX kbvBvjz+0uqDlhoXngDsfTvOxNAiVPHd4irmnQSp6Vw26YgUA= =
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.3216.1371149092.3114.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371149092 news.xs4all.nl 15955 [2001:888:2000:d::a6]:40891
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48008

Show key headers only | View raw


On 06/13/2013 02:07 PM, writeson wrote:
> Dieter,
>
> Thanks for the response, and you're correct, debugging memory leaks is tough! So far I haven't had much luck other than determining I have a leak. I've used objgraph to see that objects are being created that don't seem to get cleaned up. What I can't figure out so far is why, they are local variable objects that "should" get cleaned up when they go out scope.
>

Pure python code shouldn't have any leaks, but instead can have what I 
call stagnation.  That's data that's no longer useful, but the program 
has fooled the system into thinking it should hang onto it.

A leak happens in C code, when all the pointers to a given hunk of 
memory have gone away, and there's no way to access it any longer.

In pure Python, you don't work with pointers, but with references, and 
they are ref-counted.  When the count goes to zero, the object is freed. 
  Periodically a gc sweep happens, which catches those circular 
references which never actually go to zero.


So post a fragment of code that seems to cause the problem, and maybe 
someone can explain why.

1) objects with a __del__() method
2) objects that are "cached" by some mechanism
3) objects that collectively represent a lot of data
4) objects that are exposed to buggy C code


-- 
DaveA

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


Thread

Debugging memory leaks writeson <doug.farrell@gmail.com> - 2013-06-12 18:24 -0700
  Re: Debugging memory leaks dieter <dieter@handshake.de> - 2013-06-13 08:29 +0200
    Re: Debugging memory leaks Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-13 20:15 +0000
      Re: Debugging memory leaks Steve Simmons <square.steve@gmail.com> - 2013-06-13 22:45 +0100
      Re: Debugging memory leaks Chris Angelico <rosuav@gmail.com> - 2013-06-14 08:36 +1000
      Re: Debugging memory leaks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 02:40 +0000
        Re: Debugging memory leaks Chris Angelico <rosuav@gmail.com> - 2013-06-14 19:30 +1000
        Re: Debugging memory leaks Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-14 22:57 +0000
          Re: Debugging memory leaks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 01:39 +0000
        Re: Debugging memory leaks dieter <dieter@handshake.de> - 2013-06-15 08:52 +0200
        Re: Debugging memory leaks Chris Angelico <rosuav@gmail.com> - 2013-06-15 17:21 +1000
        Re: Debugging memory leaks dieter <dieter@handshake.de> - 2013-06-16 08:18 +0200
      Re: Debugging memory leaks rusi <rustompmody@gmail.com> - 2013-06-14 06:53 -0700
        Re: Debugging memory leaks Chris Angelico <rosuav@gmail.com> - 2013-06-15 10:11 +1000
        Re: Debugging memory leaks Ben Finney <ben+python@benfinney.id.au> - 2013-06-15 10:16 +1000
          Re: Debugging memory leaks rusi <rustompmody@gmail.com> - 2013-06-14 20:16 -0700
            Re: Debugging memory leaks Ben Finney <ben+python@benfinney.id.au> - 2013-06-15 21:23 +1000
              Re: Debugging memory leaks rusi <rustompmody@gmail.com> - 2013-06-15 04:35 -0700
                Re: Debugging memory leaks Chris Angelico <rosuav@gmail.com> - 2013-06-15 21:54 +1000
  Re: Debugging memory leaks writeson <doug.farrell@gmail.com> - 2013-06-13 11:07 -0700
    Re: Debugging memory leaks Dave Angel <davea@davea.name> - 2013-06-13 14:44 -0400
  Re: Debugging memory leaks rusi <rustompmody@gmail.com> - 2013-06-14 05:36 -0700
  Re: Debugging memory leaks "Frank Millman" <frank@chagford.com> - 2013-06-21 08:50 +0200

csiph-web