in reply to Acky Memory
Here's what I did to check:
use Gtk; Gtk->init; Gtk->set_locale; print "$$\n"; sleep 7; for(1..200) { my $o = new Gtk::Window; bless $o => 'Gtk::MJD'; undef $o; print "$_\n"; } sleep 7; package Gtk::MJD; BEGIN { @ISA = 'Gtk::Window' } sub DESTROY { my $self = shift; print "$self being destroyed.\n"; $self->SUPER::DESTROY; }
This is a little complicated. I take the Gtk::Window ibjects and re-bless them into package Gtk::MJD. This is a package that inherits all of Gtk::Window's methods, so that the objects behave exactly the same. The only exception is the DESTROY method. When Perl thinks it is time to destroy an object, because no part of the program has a reference to it any more, it will call Gtk::MJD::DESTROY. This just prints a message on the terminal and then dispatches to the real DESTROY method via SUPER::DESTROY.
The output from the program shows that the objects are not being destroyed each time through the loop. Instead they are all hanging around until the program exits, and then they are all destroyed at once.
The only thing that can prevent object destruction of an object is an outstanding reference to the object. Since you don't have one (you undefed it) someone else must have one. Therefore it's not your fault.
I suggest that you write up your problem and send it to the Gtk maintainers as a bug report.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Gtk module (not) badly behaved (was: Acky Memory)
by Aristotle (Chancellor) on Oct 27, 2002 at 13:07 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2002 at 13:57 UTC |