Re: freeing GTK+ memory

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

 



> 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
_______________________________________________
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