Re: Does GTK leak memory

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

 



On Wed, 02 Jun 2010 14:41:39 +0100 Emmanuele Bassi wrote:

> you are, of course, free to start asking people to use atexit()
> handlers to free up one-off allocations, starting from the bottom of
> the stack (font-config, freetype, X11, glibc, Mesa, etc.) and moving
> up towards gtk+.

No, please, that'd be a very bad idea. Quoting the documentation on
g_atexit:

======= 8< =======
On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
loaded module which is unloaded before the program terminates might
well cause a crash at program exit.
[...]
As can be seen from the above, for portability it's best to avoid
calling g_atexit() (or atexit()) except in the main executable of a
program.
======= 8< =======

Libraries calling atexit() is asking for trouble. I've been bitten by
that before, and it's not a pleasant experience.

If anything, the libraries would need explicit teardown functions to be
manually called by the respective users. Startup/teardown would probably
have to be reference counted (imagine a glib application with a GTK+
plugin; and GTK+ tearing down glib on plugin unload). I doubt it's
worth the hassle.

Holger
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux