Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between a memory arena and a memory allocator?

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.

like image 337
binarez Avatar asked Nov 14 '12 14:11

binarez


People also ask

What is Arena allocation?

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.

What is the use of allocator?

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.

What is Doug Lea's memory allocator?

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.

What is Arena in malloc?

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.


2 Answers

"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.

like image 111
Mike Seymour Avatar answered Oct 15 '22 04:10

Mike Seymour


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".

like image 22
Pete Becker Avatar answered Oct 15 '22 04:10

Pete Becker