RE: [gtk-list] Re: style usage + memory leak
- From: smolitor insight-tech com (Stephen Molitor)
- To: <gtk-list redhat com>
- Subject: RE: [gtk-list] Re: style usage + memory leak
- Date: Thu, 29 Oct 1998 14:01:48 -0600
Phew! What a relief. The universe makes sense again.
Seriously, thanks for the reply Owen. I didn't realize that styles were not
inherited from GtkObject. I was afraid that maybe you had to manage memory
for every widget / GtkObject you created. Having to remember to unref just
for things outside the GtkObject hierarchy doesn't seem to bad.
Steve Molitor
smolitor@insight-tech.com
-----Original Message-----
From: Owen Taylor [mailto:otaylor@redhat.com]
Sent: Thursday, October 29, 1998 1:45 PM
To: gtk-list@redhat.com
Subject: [gtk-list] Re: style usage + memory leak
smolitor@insight-tech.com (Stephen Molitor) writes:
> Robert Roebling wrote:
>
> > 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.
>
> I thought that when you created something in Gtk+, it was "floating," with
> no reference count, until you assigned it to something. So when you
create
> the style, it is "floating" (ref count 0), until you assign it to a
widget,
> raising the ref count to 1. The danger zone is when
> an object is "floating," the interval between when it is created and when
it
> is assigned to something. If you create the style and don't assign it to
> any widget, then you would have a memory leak.
That system only applies to GtkObject and its descendents
(GtkWidget, GtkAdjustment, ...)
All other things in GTK+ and GDK - GdkWindows, GtkStyle, etc,
reference count "normally" - the reference count is 1 upon
creation, and you are responsible for dereferencing them.
Often, this means creating an object, passing it to GTK+, then
unreferencing it immediately -
pixmap = gdk_pixmap_create_from_xpm_d (...);
widget = gtk_pixmap_new (pixmap, NULL);
gdk_pixmap_unref (pixmap);
Regards,
Owen
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]