slice allocator misuse?

Jasper Huijsmans jasper at xfce.org
Wed Aug 9 20:52:56 CEST 2006


Brian J. Tarricone wrote:
> -----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."
> 
> 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...
> 

That's a good question. I was under the impression that it was generally 
more efficient than malloc. I don't really know, though.

	Jasper




More information about the Xfce4-dev mailing list