Re: Does GTK leak memory
- From: Holger Berndt <berndth gmx de>
- To: gtk-list gnome org
- Subject: Re: Does GTK leak memory
- Date: Wed, 2 Jun 2010 15:58:39 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]