[10282] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: Memory leaks in glib from GTK+ 1.0.6

daemon@ATHENA.MIT.EDU (Owen Taylor)
Fri Nov 20 04:29:11 1998

To: Andreas Tille <tille@physik.uni-halle.de>
Cc: GTK User-List <gtk-list@redhat.com>
From: Owen Taylor <otaylor@redhat.com>
Date: 20 Nov 1998 04:29:05 -0500
In-Reply-To: Andreas Tille's message of "Fri, 20 Nov 1998 09:05:41 +0100 (MET)"
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


Andreas Tille <tille@physik.uni-halle.de> writes:

> Hello,
> 
> I've detected the reason for three memory leaks in glib from
> the GTK+ 1.0.6 distribution.  It is the global variable
> _GRealListAllocator.  Here is a code snipped from glist.c:

> When a g_list is allocated this struct allocates three pointers
> which will never be freed and I didn't see any clue, how to do
> that, because they are hidden for the application.  

This is completely intentional. The idea is that over time,
the number of GList nodes that a application will use is
approximately constant. So, instead of taking the overhead
to constantly malloc and free the list nodes, once a
list node is freed, it is just added onto a global free-list
for future use.

(Note that there quite a few static structurs in GTK+ that
 are allocated once and kept around ever after. Since everything
 is freed upon exit anyways, there is little point to 
 trying to free() these structures before exiting. This may
 make it a little difficult to try and trace memory usage
 with dmalloc. Commercial tools basically do GC-style checks
 so they can identify blocks that cannot be reached at all)

Regards,
                                        Owen

-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post