6 ms·
Pardon my ignorance, but this bump-allocator looks like a reinvention of arena-allocators. Is there something I’m missing?
by DaiPlusPlus 3y ago
Pardon my ignorance, but this bump-allocator looks like a reinvention of arena-allocators. Is there something I’m missing?
- NobleExpress 3y agoThey're (effectively) the same. Bump allocation is the term in GC literature and is the more general term. Arena allocation can be slightly more nuanced as you can throw an entire arena away after you're done with it (if your problem domain allows for it). But arena allocation is just a kind of bump allocation for all intents and purposes.
- adamrezich 3y agoI've heard the terms used interchangeably.
- kazinator 3y agoBump allocation specifically means doing nothing but moving a pointer by a displacement related to the object size. While "arena allocator" is also used for the same thing, it doesn't exclusive have that meaning. It also refers to region-based memory management in general. An arena allocator can be versatile, allowing objects of different sizes to be freed in any order, and coalesced for new allocation. The arena part of is that the application can throw the whole arena away in one operation. Bump allocation isn't always used inside arenas that can themselves be allocated or freed. It can be global also. Operating system kernels use such an approach for initialization-time allocation of permanent objects. The classic Unix sbrk() mimics that.
- o11c 3y ago"Arena" is a heavily overloaded term. Usually arenas have more logic than a mere bump allocator though. Sometimes "arena" means "thread-local cache", so objects can be free'd to a different arena than they came from, etc. Arenas might be a single finite-size underlying allocation or contain multiple of those dynamically. Arenas might be able to answer the question "did this arena allocate this pointer originally"? Arenas might be user-facing objects or internal implementation details only.