Re: RFC: Reference counts on Gtk2::Tooltips
- From: Andrew Pimlott <gtk-perl-list andrew pimlott net>
- To: gtk-perl-list gnome org
- Subject: Re: RFC: Reference counts on Gtk2::Tooltips
- Date: Mon, 5 May 2003 16:15:57 -0400
On Mon, May 05, 2003 at 04:16:42PM -0400, muppet wrote:
Andrew Pimlott said:
On Mon, May 05, 2003 at 03:46:43PM -0400, muppet wrote:
well, there's not really a way to leak the tooltips reference in perl,
because the wrapper will clean up the object when the time comes. in C,
this object is leaked simply by virtue of not calling _unref on it.
When does the time come?
G::Object::DESTROY *always* calls g_object_unref (provided the pointer is not
NULL (which shouldn't happen)).
DESTROY is called when the last reference to the perl scalar goes away. the
perlobj manpage describes this. (i would swear there's another place that
gives examples but i can't find it.)
That's what I thought you meant, ok.
I'm confused, but maybe I'm just thinking of the terms differently. If you
put the tooltip in a global variable (or inside some global data structure)
and then forget about it, that's a leak to me.
but it's not leaking for real, because perl still knows that it exists and
will call DESTROY on it when that reference goes away. the leak to which i
refer is the genuinely unrecoverable leak for which C is so famous and which
can cause resource exhaustion and crashes (you can't free it if you don't know
That's what I thought, too. This sort of dissonance always seems to
come up around the subject of memory leaks. :-)
but have no fear --- your argument that providing the workaround doesn't hurt
anybody, doesn't change the behavior, *and* helps avoid a common and obviously
hard-to-explain pitfall is the best one, so the fix is going in.
] [Thread Prev