Re: GSlice with tight memory (Re: Help Needed)



Tim Janik <timj imendio com> writes:

> whether you benefit in terms of memory size by using GSlice instead of
> malloc/free depends heavily on your application. simply watch your
> memory requirements with G_SLICE=always-malloc and without it.

In general, I'd recommend just always using

        g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, 1);

This way the various tools, valgrind and memprof, will work with your
application, and you don't get any surprises with pathological cases
causing run-away caching. The speed difference between g_slice and
g_malloc is basically noise as soon as you include the time to
initialize the new block of memory.

If it does turn out that malloc() shows up on a profile (either memory
or speed), those specific cases can be fixed. With application
knowledge you can do a better job than any general purpose allocator.


Soren



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