Moises, in case Emmanuele's comments were unclear: In C, the contents of data structures are often still available after you have freed or destroyed the object which notionally contains that data. As long as the underlying memory is still addressable (which is usually the case) you can still read it -- if the same address space in memory is allocated for a new data structure later on, only then will you probably notice the problem. On Thu, May 1, 2008 at 2:36 AM, Emmanuele Bassi <ebassi@xxxxxxxxx> wrote: > > On Wed, 2008-04-30 at 19:10 -0500, Moises wrote: > > > when I use g_object_unref decreases reference count > > and when this hit 0, the object is released, but when > > does it hit 0? > > when the last reference, created by the construction of an object, is > removed. > > instance = g_object_new (type, ...); > ... > g_object_unref (instance); /* the object is disposed */ > > > > when the program ends and eventually > > released all memory or immediately that I used > > g_object_unref?. > > if g_object_unref() has been called and it was the last reference then > the object is disposed and the instance becomes a pointer to an invalid > object. > > > > because apparently does not work because I have the > > following > > > > imgPixbuf = gdk_pixbuf_new_from_file(xfileName, > > error); > > ... > > g_object_unref (imgPixbuf); > > > > but still I get data of pixbuf with: > > you are get garbage, which does not segfault on you for a simple matter > of chance. unless the "..." in between did not increase the reference > count of the object. > > > > imgPixbuf = gdk_pixbuf_new_from_file(xfileName, > > error); > > ... > > g_object_unref (imgPixbuf); > > width=gdk_pixbuf_get_width(imgPixbuf); > > > > then the object is not destroyed > > the object is disposed, but not set to NULL. no free/dispose function > will set the pointer to NULL for you - at least, not in GLib. > > > ciao, > Emmanuele. > > -- > Emmanuele Bassi, > W: http://www.emmanuelebassi.net > B: http://log.emmanuelebassi.net > > _______________________________________________ > > > gtk-list mailing list > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list > -- http://www.socsurveys.org/ http://blogger.socsurveys.org/ http://del.icio.us/hdon http://hdon.soup.io/ _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list