Re: g_blow_chunks() doesn't. (Brett Viren) writes:

> Hi.
> I am using GLib's g_slist_*() functions.  After each cycle of my
> program I am freeing all lists which I have used with either
> g_slist_free() or many g_slist_remove()'s and then calling
> g_blow_chunks() (great name!).
> However, I don't think it is actually freeing any of the slist's
> chunks (as it should according to comments in glib.h), because when I
> call g_mem_chunk_info() I get, among others, a line like:
>         slist mem chunk: 79704 bytes using 80 mem areas
> If I run my code so that each program cycle needs more links per list
> than the previous, then this count increases.  If I run it so that
> each program cycle needs less links per list, then this count stays
> the same, so I am pretty sure I'm not forgetting to g_slist_free() all
> my lists.
> Since some times I will need to use much longer lists than others I
> would like to free up this list memory whenever possible.
> Can someone tell me what I am missing?

For the maximum in speed, GSLists allocate their nodes from
a ALLOC_ONLY mem chunk; when nodes are freed, they aren't
freed in the memchunk, they are just added to a slists free

The assumption is that if your program is using a lot of
list nodes now, then it will be again shortly, so trying
to actually free the memory isn't that important.

(g_mem_chunk_free() is actually sort of expensive; since
[S]Lists are used so much this is an important speedup.)


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