bumpalo will allocate 3M, because third allocation will create third chunk double the size of second chunk.
Instead bumpalo could do the following: if allocation size is larger than 1M, always allocate in the fresh chunk of size exact of allocation size, attach it to the tail of current chunk, and then continue allocating in the current chunk.
This will break this invariant of iter_allocated_chunks:
/// The chunks are returned ordered by allocation time, with the most
/// recently allocated chunk being returned first, and the least recently
/// allocated chunk being returned last.
Consider this scenario:
bumpalo
will allocate 3M, because third allocation will create third chunk double the size of second chunk.Instead
bumpalo
could do the following: if allocation size is larger than 1M, always allocate in the fresh chunk of size exact of allocation size, attach it to the tail of current chunk, and then continue allocating in the current chunk.This will break this invariant of
iter_allocated_chunks
: