Re: Memory leaks in glib from GTK+ 1.0.6
- From: Owen Taylor <otaylor redhat com>
- To: Andreas Tille <tille physik uni-halle de>
- Cc: GTK User-List <gtk-list redhat com>
- Subject: Re: Memory leaks in glib from GTK+ 1.0.6
- Date: 20 Nov 1998 04:29:05 -0500
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]