This is more a semantic question than a coding question....
What's the difference between a memory arena and a memory allocator?
I'm working in C++ and I'm seeing some memory management libs using concepts like "memory arena", "memory allocator" and sometimes both in the same lib.
I know what an allocator is; I'm just not sure what a memory arena is if it's not just another word for allocator.
One type of custom allocation technique that has proved to be useful in some cases is arena-based allocation, which allows the user to quickly allocate objects from a large contiguous region of memory.
Allocators handle all the requests for allocation and deallocation of memory for a given container. The C++ Standard Library provides general-purpose allocators that are used by default, however, custom allocators may also be supplied by the programmer.
This allocator provides implementations of the the standard C routines malloc() , free() , and realloc() , as well as a few auxiliary utility routines. The allocator has never been given a specific name. Most people just call it Doug Lea's Malloc, or dlmalloc for short.
An arena represents a pool of memory that can be used by malloc(3) (and similar) calls to service allocation requests. Arenas are thread safe and therefore may have multiple concurrent memory requests. The trade-off is between the number of threads and the number of arenas.
"Memory arena" typically means a large lump (or collection of lumps) of memory from which smaller lumps are allocated. The word "pool" is also commonly used for such a thing.
"Memory allocator" typically means the software that determines how to allocate memory from an arena.
Strictly speaking, a "memory arena" is a pool of memory that a "memory allocator" allocates memory from. But I wouldn't be surprised to see "memory arena" used as a synonym for "memory allocator".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With