Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I only recently learned about bump allocators. I was very confused as to how such an allocator could be useful. In reading the author's bumpalo crate [1] documentation, he cleared up my confusion.

For one thing, this particular allocator is separate from the general allocator so the calling code can choose when to use the bump allocator.

Quoting the crate doc:

> [B]ump allocation [is] well-suited for phase-oriented allocations. That is, a group of objects that will all be allocated during the same program phase, used, and then can all be deallocated together as a group.

I can see this being useful as a way to optimize allocation/deallocation speed for specific use-cases.

[1] https://docs.rs/bumpalo/latest/bumpalo/



It's great when you don't need destructors and have a bunch of small objects to allocate with similar lifetimes.


It is also used in WASM. I guess to increase memory safety


Bump allocators are very simple in an environment where everything you want must be brought with you.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: