Anyway, it seems that the objects are not being destructed properly, as you said. This is because some other part of the program that you can't see still has references to them. Each object might have a reference to itself (or to some other object that refers to it) or the Gtk module might have some data structure that refers to all 200 objects. I don't know where these references are, or how to fix them---it is a bug in Gtk that you might want to report.

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.


In reply to RE: Acky Memory by Dominus
in thread Acky Memory by jettero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.