Rob Kendrick wrote:

> On Wed, 28 Apr 2010 20:14:51 +0100
> James Peacock <[email protected]> wrote:
> 
>> I think you've missed my poiny. It is more that just 'slab'
>> allocation. The important thing is allocating blocks with similar
>> lifetimes from the same pool. This cannot be done by malloc as there
>> is no way to pass that information to it.
> 
> Lots of data is shared between contents (interned strings, images,
> possibly style sheets); there's no way to calculate the lifetime of
> objects.

I don't know NetSurf so could be way off the mark. Clearly the 
benefit, if any, would depend on the allocation patterns and the sizes 
of the objects.

In the case I mentioned earlier almost all of this allocation was 
temporary (e.g. within a single function call), but it was the 
differing lifetimes of these temporary objects which made malloc 
struggle to reuse memory efficiently and keep asking for more.

However, this doesn't solve the problem of large, long term 
allocations. For really big things like large images, I think you 
probably have to shift them about occasionally to avoid fragmentation.

James

Reply via email to