Memory leak in Tkinter?????

Elbert Lev elbertlev at hotmail.com
Sun Jul 25 22:38:30 CEST 2004


klappnase at web.de (klappnase) wrote in message news:<a7a67196.0407241601.4e10cbc6 at posting.google.com>...
> elbertlev at hotmail.com (Elbert Lev) wrote in message news:<9418be08.0407231106.42f0bdde at posting.google.com>...

> I don't see a memory leak here on my linux box; there's a noticeable
> increase of memory use if I close/reopen the window a few times within
> a couple of seconds, but after about 5 seconds it disappears, so it
> looks like python's garbage collection works properly (are you aware
> that calling "del" does not free the memory immediately but just
> remove the reference to the deleted object so it can be garbage
> collected later on).

I don't think this is a correct statement. Python uses refference
counting. So, as soon as rc goes to 0, object is deleted. This can be
done several ways:

a = list(1,2,3)
del a # a is deleted

or

a = list(1,2,3)
a = 0 # list content is deleted and new object is created

See Language Reference 3.1 for more details.

Python isn't Java and DOES NOT HAVE lazy garbage collection (but you
can call it manualy. In this case ciclic references are counted and
resolved). I checked them and the number of items in gc.garbage was 0

> Why do you use the "while 1" condition to create your "dialog box"?
> Notice that you create and endless loop without any "break" condition,
> there's no way to stop the program from the gui itself which is
> definitely no good idea.
> Besides this you should be very careful using "while 1" statements in
> any case.
.................
> I don't have windows or mac here, but on my linux box it looks like
> the only thing that's wrong is the code.

Sure while 1: is a test case, sure the program shows a simple dialog
box, but you missed the point - this is a test case to check if there
is a leak or not.

I repeated the test in windows and I do not see "delayd release".



More information about the Python-list mailing list