Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too large allocation because of doubling last allocation #152

Open
stepancheg opened this issue May 9, 2022 · 0 comments
Open

Too large allocation because of doubling last allocation #152

stepancheg opened this issue May 9, 2022 · 0 comments

Comments

@stepancheg
Copy link
Contributor

Consider this scenario:

  • allocate 10 bytes
  • allocate 1 Mb
  • allocate 10 bytes

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant