Re: RFC: Reference counts on Gtk2::Tooltips



Andrew Pimlott said:
On Mon, May 05, 2003 at 03:29:53PM -0400, Ross McFarland wrote:
preserving the c behavior will not leak tool tips they will be unrefed and
destroyed when the block in which the var was created goes out of context.
in this way perl does not have the memory leak whereas a similar c program
would have.

But having the tooltip die when the scope ends is exactly what
triped the pitfall in the original example.  Your argument only
holds when the widget (to which the tooltip is attached) is also
local to the scope.  If the programmer cannot take advantage of
block-local variables, how is he to avoid the memory leak?

a C program can leak the object because the C programmer doesn't have to call
g_object_unref.  gtk2-perl-xs takes care of reference-count management and
calls g_object_unref for you at the right times, so that you can't leak an
object the way you can in C.

avoiding the leak is not the problem.  keeping the object alive is.



-- 
muppet <scott at asofyet dot org>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]