Wireshark-dev: Re: [Wireshark-dev] g_mem-chunk_destroy does not free memory for GLib > 2.8

From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Sat, 10 Oct 2009 10:18:58 -0400
Bill Meier wrote:

<snip>

If there is no simple way to free up what may be an array of many multiple slices, I'm inclined to replace the use of GMemChunk (at least for those cases) by the use of GArray.

After a quick look, one concern I have is about constantly extending a GArray thus causing a copy each time. I note that it does seem that space for multiple entries can be pre-allocated. So: a wrapper for GArray could be coded which more or less does what I GMemChunk used to do. Or: does GArray have some builtin optimization ?

Looking at the GLib source for GArray I see that there is built-in optimization with respect to allocating space when an item is added to an array.

So: memory allocation appears to not be an issue when using GArrays.