slice allocator misuse?

Nick Schermer nickschermer at gmail.com
Wed Aug 9 20:59:32 CEST 2006


2006/8/9, Brian J. Tarricone <bjt23 at cornell.edu>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 8/9/2006 11:36 AM, Jasper Huijsmans wrote:
>
> >  * Use g_slice_* functions when available at compile time.
>
> Why are we going nuts about the slice allocator?  From the glib docs:
>
> "Memory slices provide a space-efficient and multi-processing scalable
> way to allocate equal-sized pieces of memory, just like the original
> GMemChunks (from GLib <= 2.8), while avoiding their excessive
> memory-waste, scalability and performance problems."
>

>From the same doc: [...] For newly written code it is recommended to
use the new g_slice API instead of g_malloc() and friends, as long as
objects are not resized during their lifetime and the object size used
at allocation time is still available when freeing.

> This makes sense for some things, like allocating arrays that need to
> grow and shrink (actually maybe not even here), or repeated alloc/free
> in a loop, or lots of instances of the same struct, etc.  But why for
> things like one-time dialog structs, etc.?  I guess the questions is: is
> a single g_slice_alloc() faster than a single g_malloc()?  If not, some
> of these 'use the slice allocator' patches are seriously misusing it...
>

Maybe the dialogs are a bit 'overkill', but it probably doesn't matter.

Nick

>         -brian
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (MingW32)
>
> iD8DBQFE2i3i6XyW6VEeAnsRAtWCAKDGjJ8U5clRhbBSWSDOyAWe3A6SHQCgmTHe
> LYJL76026wkq9mrW9BfaAOg=
> =nmkr
> -----END PGP SIGNATURE-----
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://foo-projects.org/mailman/listinfo/xfce4-dev
>



More information about the Xfce4-dev mailing list