Re: [patch] [bug 461795] reduce some small allocations

On Mon, 2007-12-03 at 14:21 +0100, Tom Parker wrote:
> On 03/12/2007, Christian Persch <chpe gnome org> wrote:
> > attached patch from bug
> > removes some small allocations, and makes other use GSlice.
> Briefly wondering about the sizes of some of the buffers - you're
> allocating 32 bytes for lots of different things, both stuff that's
> just an int and stuff that's "some text" + an int. Do the int-only
> ones need to be 32 bytes, and conversely is 32 bytes big enough for
> the "some text" cases? It's picky, but this patch is addressing some
> pretty small memory changes. AFAIK, provided GINT_MAX stays at 2^32
> (true on 64-bit?), then we only need 9 characters max, so it should be
> ok, but this is an area where g_strdup_printf would always do the
> right thing regardless of what happens in the future.

The size of the allocation is not the point. The 32 bytes are on the
stack and will be immediately freed after the function returns. The
point is that its both faster than dynamic allocation, and it doesn't
fragment the heap.

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