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




Hmm.. it does appear that all objects have a reference count of one
when created.  I suppose the clean way is to do an unref on each
object you create (ug..) during the program.  Otherwise, this
certainly could cause leaks if you don't keep track of the memory.

To let GTK keep free the objects, could just unref the style after
assigning it to the window.  Don't know what kind of damage that might
do.  <g> 

Don't know about the memory hogging though.  Might try replacing
g_malloc with something more informative that keeps track of who's
allocating the memory.  Might show what's going on. 

 -Eric

---Robert Roebling <roebling@sun2.ruf.uni-freiburg.de> wrote:
>
> 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
> 
> 

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com



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