[9635] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: style usage + memory leak

daemon@ATHENA.MIT.EDU (Robert Roebling)
Thu Oct 29 10:40:37 1998

Date: Thu, 29 Oct 1998 17:24:45 +0100
From: Robert Roebling <roebling@sun2.ruf.uni-freiburg.de>
To: gtk-list@redhat.com
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com

Eric Harlow wrote:

> You should not be calling unref unless you are also making the ref
> call.  If you just call the unref (as in your example), this should
> end up freeing the style you just created.

No. When I create the style, its ref count is 1. When I then
assign it to a widget, I assume the widgets will raise the
ref count to 2. Without unref after assigning it the widget
would unref the style upon its own destruction leaving
the ref count at 1 -> memory leak.

> GTK keeps track of memory pretty well and you should rely on GTK 
> to do that work for you.  

Daring thesis. Also GTK+ cannot handle memory on its
own, you'd still have to know when to unref unless you
use C++ which can do that itself. wxWindows does it for
you - as an aside...

And I'm still wondering about the 1100 memory leaks reported
by dmalloc. It could be a cashing function. I hope it is.

  Robert

-- 
------------------------------------------------------------------
Robert Roebling              "Write once, compile, run everywhere"

wxWindows/GTK       http://wesley.informatik.uni-freiburg.de/~wxxt

-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post