Re: g_malloc overhead



On Wed, 2009-01-21 at 10:21 +0100, BJörn Lindqvist wrote:
> 2009/1/21 Liam R E Quin <liam holoweb net>:
> > On Mon, 2009-01-19 at 18:43 +0100, BJörn Lindqvist wrote:
> >> Actually, a custom allocator could be useful even in the general case.
> >> Malloc is a system call and has quite bad performance on certain
> >> platforms (windows in particular i think). Something like the gslice
> >> allocator could
> >> Probably improve performance a bit.
> >
> > malloc is a library call.
> 
> On Linux, it is implemented using mmap() and brk() which are system
> calls.

brk(2) is called to grow the heap, but not on every malloc() call;
mmap(2) is used only for large objects, and then not always.

If you malloc() a few megabytes and then call free, a program
that allocates a lot of small objects may well go faster on some
systems, and slower on others.

Yes, g_slice was tested, but the program _calling_ g_slice is in
the domain of the user, and errors in calling g_slice or malloc()
can be hard to debug.

No more from me on this.

Liam

> 
-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org



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