Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48008
| Date | 2013-06-13 14:44 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Debugging memory leaks |
| References | <09917103-b35e-4728-8fea-bcb4ce2bd1af@googlegroups.com> <ddaedafc-ed0c-45e1-a9bf-146aaff88d16@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3216.1371149092.3114.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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