473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3337

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
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...
2
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...
10
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
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,...
5
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...
8
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...
28
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...
56
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 =...
158
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.