Re: dispose and finalize
20.01.10, 17:56, "Martin Kalbfuß" : > Hi, > what's the difference between dispose and finalize? And which members > have to be freed in which of these functions? > Thanks In dispose you should drop all references to other GObjects. In finalize you free other data (char *, GArray *, etc.) "dispose" can be invoked more than one time before "finalize". See also [1], specifically last section. [1] http://library.gnome.org/devel/gobject/stable/gobject-memory.html -- Artur ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: dispose and finalize
On Wed, 20 Jan 2010 18:20:39 +0100 Martin Kalbfuß wrote: > So if I have a Garray member, I call g_array_unref in finalize, > because it isn't a child of GObject. Correct? Actually, I would decrement the reference count of all reference counted objects in dispose. Speaking of GObject is probably an over-simplification. I am not sure if that's strictly required, but it sounds safer anyways. Holger ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: dispose and finalize
OK Thanks, So if I have a Garray member, I call g_array_unref in finalize, because it isn't a child of GObject. Correct? Am Mittwoch, den 20.01.2010, 17:24 +0100 schrieb Holger Berndt: > On Wed, 20 Jan 2010 17:56:18 +0100 Martin Kalbfuß wrote: > > > what's the difference between dispose and finalize? And which members > > have to be freed in which of these functions? > > See http://library.gnome.org/devel/gobject/unstable/gobject-memory.html > > The difference in short: > > dispose: > - g_object_unref() all GObject member variables > - function must be safe against being called multiple times > > finalize: > - free all other (non-GObject) members, close file descriptors etc > > Holger ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: dispose and finalize
On Wed, 20 Jan 2010 17:56:18 +0100 Martin Kalbfuß wrote: > what's the difference between dispose and finalize? And which members > have to be freed in which of these functions? See http://library.gnome.org/devel/gobject/unstable/gobject-memory.html The difference in short: dispose: - g_object_unref() all GObject member variables - function must be safe against being called multiple times finalize: - free all other (non-GObject) members, close file descriptors etc Holger ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
dispose and finalize
Hi, what's the difference between dispose and finalize? And which members have to be freed in which of these functions? Thanks ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list