Re: freeing GTK+ memory
- From: "Tor Lillqvist" <tml iki fi>
- To: "Pablo Yanez Trujillo" <yanezp informatik uni-freiburg de>
- Cc: gtk-list gnome org
- Subject: Re: freeing GTK+ memory
- Date: Fri, 17 Oct 2008 01:20:14 +0300
> Even a small programm like
> int main(int argc, char **argv) {gtk_init(&argc, &argv);return 0;}
> has 619 non-free blocks. Why? Is there a function to free this memory?
Yes. It's called exit().
I.e. it is not expected that a program that uses GLib and GTK+ will
use their API, then stop using it but still keep running for a long
time. Such a scenario would be the only case in which it would matter
that GLib and GTK+ internal dynamically allocated data structures are
still allocated even if unused when no GLib and GTK+ functionality is
used any more.
If you really plan to write such a program, then one (untested, by me
at least) solution would be to write your own set of malloc family
wrapper functions that keep track of allocations. Then pass those to
g_mem_set_vtable() (see docs for that) before your first GLib (or
GTK+) call, and when totally done using GTK+ and GLib, free all the
memory that you have allocated in these wrappers. That might work.
--tml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]