Hi, For Totem we use dispose to unref any objects and finalize to free any private memory and close any sockets/DB connections/other fluff, which is (I believe), how you're supposed to do it. If you only use dispose you'd have to put a lock variable in to stop any private memory getting freed multiple times if dispose is called more than once. If you only use finalize then you could theoretically get unbreakable cyclic references. At the end of the day, if it works then it's probably OK; you just might run into maintenance issues further down the line if you forget that you didn't protect the call to g_free on your private memory, or that you didn't cater for cyclic references by using dispose. Regards, Philip On Sat, 2008-03-22 at 23:23 +0100, Jaap A. Haitsma wrote: > Hi, > > When I look at projects like gnome-screensaver and gnome-power-manager > I see that for their own created gobject types only the finalize > function is implemented to cleanup the resources in the end of the > application. > > gnome-volume-control uses only implements the dispose function > > I understand from [1] that the two cleanup function dispose and > finalize exist to make bindings to languages with garbage collection > easier. So I guess for libraries for which other language bindings > might be written it's a good thing to follow the recommendation in [1] > of what to do in finalize and dispose. > > So what is recommended for applications? > 1) implement dispose and finalize as recommended > 2) only finalize > 3) only dispose > > Jaap > > [1] http://library.gnome.org/devel/gobject/unstable/gobject-memory.html > _______________________________________________ > desktop-devel-list mailing list > desktop-devel-list gnome org > http://mail.gnome.org/mailman/listinfo/desktop-devel-list
Attachment:
signature.asc
Description: This is a digitally signed message part