473,563 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gc.DEBUG_LEAK and gc.garbage

Hi,

I am new with python, and I am having a look to program that leaks.
The first thing I have to do is to determine if what leaks it is the
python code of my company.

I have set the DEBUG_LEAK flag with the GC and in the program cycle
printed the length of the garbage list. Is this enough to determine if
there is a leak in the python code? (the value rises). I am not
totally sure (see below).

I played with other flags as DEBUG_SAVEALL, but I think they are not
useful for what I want.

Finally, in this group I have seen a reference to an article in which
they had the look to gc.garbage after calling explicitally to
gc.collect(). is this necessary?

Thanks, Cesar
Jul 19 '05 #1
2 3344

Cesar> I have set the DEBUG_LEAK flag with the GC and in the program
Cesar> cycle printed the length of the garbage list. Is this enough to
Cesar> determine if there is a leak in the python code? (the value
Cesar> rises).

That suggests to me that you have objects with __del__ methods that are
involved in cycles. Get rid of the __del__ methods or figure out some way
to break the cycles.

Cesar> Finally, in this group I have seen a reference to an article in
Cesar> which they had the look to gc.garbage after calling explicitally
Cesar> to gc.collect(). is this necessary?

Generally, no, but if you want to make sure the collector has run when you
want to look at gc.garbage it's convenient to call gc.collect() first.

Skip
Jul 19 '05 #2
Cesar wrote:
I have set the DEBUG_LEAK flag with the GC and in the program cycle
printed the length of the garbage list. Is this enough to determine if
there is a leak in the python code? (the value rises).
Well, define "a leak". It could mean a number of things:

- an object that is not used anymore, but still referenced
from a "live" object.
This will not be released until the reference from the live
object is broken.
- an object that is not referenced "from the outside", but
still referenced from a cycle. It will not be released immediately,
but will be released eventually when the cyclic GC runs.
- an object that is part of a cycle, but not even released by
the cyclic GC.
- an object that is never released because its reference counter
is wrong.

Except for the last category, none of these are "true" leaks,
since you could always arrange to release them eventually through
explicit Python code.
I played with other flags as DEBUG_SAVEALL, but I think they are not
useful for what I want.
DEBUG_LEAK includes DEBUG_SAVEALL; all objects in cycles are not
released, but added to gc.garbage. This is to detect whether
you have objects that are not released even when they become
unreachable, but only when the GC runs. Some people consider
this a leak, and DEBUG_LEAK helps you to find such objects
(so you can break the cycles explicitly).

If you want to know whether you have objects that participate
in cycles and are not released by the cyclic GC, then don't
set any flags, and just look at gc.garbage.
Finally, in this group I have seen a reference to an article in which
they had the look to gc.garbage after calling explicitally to
gc.collect(). is this necessary?


Necessary to do what? If you want to verify that all unreferenced
objects are collectable, you should check gc.garbage after invoking
gc.collect().

Regards,
Martin
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2300
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and then throws them away and then monitors the garbage collection and store statistics on it, preferably in C#. I want to know what is the longest...
2
1734
by: Oculus | last post by:
Before I get into the question -- I know .NET isn't the right solution for this app but it's part of my clients requirements and writing this in C++ isn't an option. That being said -- my app is a stock ticker using the managed DirectX libraries and the animation needs to be perfectly smooth. Problem is that the garbage collector will kick in...
10
2014
by: pachanga | last post by:
The Hans-Boehm garbage collector can be successfully used with C and C++, but not yet a standard for C++.. Is there talks about Garbage Collector to become in the C++ standard?
34
6375
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple, probably a few hundred lines of code in Python. There is a need to interact with network using the socket module, and then probably a need to do...
5
5484
by: Ben | last post by:
Could someone please verify if what I am doing as follow is corrected: 1. when dealing with custom class objects: ..... public myObject as myClass myObject as New myClass .......here I am going to fill up myObject with info....tons of them myObject = nothing System.GC.Collect()
8
3026
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by the mainline. The class that instantiated the object in question is definitely still in existence at the point garbage collection swoops in and...
28
3146
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will this work be library based or language based and will it be based on that of managed C++? Then of course there are the finer technical questions...
56
3634
by: Johnny E. Jensen | last post by:
Hellow I'am not sure what to think about the Garbage Collector. I have a Class OutlookObject, It have two private variables. Private Microsoft.Office.Interop.Outlook.Application _Application = null; Private Microsoft.Office.Interop.Outlook.NameSpace _Namespace = null; The Constructor: public OutlookObject()
158
7736
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is discouraged due to some specific reason. If someone can give inputs on the same, it will be of great help. Regards, Pushpa
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.