Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old March 26th, 2004, 06:12 AM
frederikfix frederikfix is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 frederikfix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
memory debugging

Hi,
I have developed a rather large program in python that leaks memory somewhere. However I have no idea where. Does anyone know of tools that can help with finding memory leaks in python?
Alternatively is there some way to query the amount of memory a program uses from within python?

Thanks in advance,
Frederik Fix

Reply With Quote
  #2  
Old March 26th, 2004, 09:56 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
I've never had much a problem with memory leaks in Python and have only got a MemoryError once in the time i've used it so Python seems to be pretty good at limiting this. In any case manybe these likes will help:

http://www.nightmare.com/medusa/memory-leaks.html
http://zope.org/Members/mcdonc/HowT...ndDebugMemLeaks - Python and Zope

You might also like to check out pythons profiler modules although i'm not sure if they show memory usage or not...

http://www.python.org/doc/2.3.3/lib/module-profile.html
http://www.python.org/doc/2.3.3/lib/module-hotshot.html

But if you fire up your browser and search google a little i'm sure you'll be able to find what your looking for .

Hope this is of some help,

Mark.
__________________
programming language development: www.netytan.com Hula


Last edited by netytan : March 26th, 2004 at 09:59 AM.

Reply With Quote
  #3  
Old March 26th, 2004, 10:18 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,196 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 13 h 42 m 7 sec
Reputation Power: 252
If you are using a modern version of Python that has been compiled with garbage collection enabled, then you can use the 'gc' module in the standard library to get information about the objects known to the garbage collector, force garbage collection, trace object creation and deletion, etc. RTFM for full information.


For earlier versions of Python there is a tool called Cyclops written by Python Guru Tim Peters. This tracks down and reports cyclic object references. It is rather dated (1999) but should still work with current versions of Python. You can find it on the Python.org FTP server - http://www.python.org/ftp/python/co...ec-1999/System/. There may be more recent versions around, but I have not found any. If garbage collection is enabled then cycles should not be such a problem unless an object cannot be freed by the GC.

There is also a function in the sys module 'getrefcount' that you can use to find out how many reference there are to an object.

Between these three, you should be able to track down any leaks in your Python code. Leaks in extension modules is another matter.

Hope this helps,

Dave - The Developers' Coach

Last edited by DevCoach : March 26th, 2004 at 10:42 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > memory debugging


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway