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

Re: [patches] malloc & madvise



On Mon, 16 Nov 2009, Richard Kralovic wrote:

> I tried to implement the following approach: Malloc keeps track about
> each block of consecutive free pages that have not yet been returned to
> OS. In each free chunk there is a doubly linked list of such blocks,
> sorted according to the block addresses. Furthermore, there is one
> central doubly linked list of all such blocks sorted according to the
> creation time. Once the total free space in the blocks exceeds
> M_TRIM_THRESHOLD, some of the blocks are returned to OS via MADV_DONTNEED.

I'm not an expert on the malloc internals, but one thing to consider when 
changing internal datastructures like this is whether you keep 
compatibility for malloc_set_state/malloc_get_state: whether a binary 
(most likely emacs) with saved state from malloc without this change will 
reliably work with libc with this change, and vice versa.  If it won't, 
there are ABI issues and it may be necessary to go (by default) with a 
dumber approach that doesn't need to keep extra state.

-- 
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx