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



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



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