I am reading a book on Assembly and I can across this section
In this type of environment, memory pools work really well. Memory pools are like multiple areas of memory from which you can request allocations and deallocations. Imagine segmenting out your memory so that not only do you request an amount of memory you want, you also request which memory pool you want it allocated from.
…
Rather than having to manage all these pointers to be sure you free them all at the right time, what if you could just say, “Hey computer—free everything that I allocated for this request!” Memory pools allow you to do this.
I have heard about Arena Allocator in Zig, and the “memory pool” described sounds exactly like what Arena allocator’s implements in Zig.
Would I be correct to say that? Are Zig’s Arena Allocator an implementation of the idea of memory pools? or there is a difference?
I encourage you (and anyone else interested/curious about it) to read the source code of Zig’s ArenaAllocator. It’s pretty short and understandable (you can ignore reset which takes up a lot of the lines of code), and afterwards you might be able to answer your own question(s).
Arena: Allocations of different sizes that are stacked on top of each other in continuous memory blocks of increasing size.
Deallocation is only possible by releasing the most recent allocation or by freeing all blocks.
Example: Game engine frame data. Pool: A contiguous block of memory divided into fixed-size chunks. By letting free chunks form a linked list, chunks can efficiently be freed in arbitrary order and reused later.
Example: Network packet pools.
I’m pretty sure the quote is talking about the same kind of memory pool. Although at the assembler level it would just mean fixed-sized blocks, since there’s not much in the way of types going on.
That said, “allocator of fixed sized blocks, with a freelist for rapid reuse” is the only definition of memory pool I’ve ever seen.