Re: Gnome and Gtk applications have memory leaks?




Bruno Abrunhosa Pires Marinho <bapm@camoes.rnl.ist.utl.pt> writes:

> Hi fellows.
> 
> Maybe someone already discussed this but here it goes:
> 
> After using gnome applications I found out that applications don't free
> memory used on widgets. Using gtop and following the memory usage of one
> of the gnome applications like gtt I found that the memory usage increases
> every time I open a dialog box but the memory usage does not decrease
> after I close the dialog box and even increases again if I open the same
> dialog box again. This means that the program doesn't free memory used on
> widgets. This is a big problem because linux does not crash too often and
> we can be using an application for too long. This leads to the fact that  
> we might end up with an application that eats all the memory.

There is no reason in GTK+ that this should leak memory; no
special attention is normally needed in GTK+ to freeing widgets.

However, particular applications may be leaking memory; either
because they are leaking widgets, or because they are leaking
memory for other reasons.

(one way to debug widget leaks is to compile GTK+ with --enable-debug
and then run 

  GTK_DEBUG=objects foo

Note that if the app doesn't free all its widgets at shutdown,
this may show harmless warnings)

> All this leads to the fact that programmers are not well informed on gtk 
> and gnome tutorials that they must free widgets after using them if they 
> are not going to be used later. 

Generally, you don't need to. Simply make sure that toplevel
widgets are destroyed after you use them.

(There are some special stuff you need to do if you create
non-toplevel  widgets that are never added to a parent widget,
but that is an unusual and advanced topic)

Regards,
                                        Owen



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