Home / Forums / Building a High-Performance Linear Bump Allocator (Arena) in C++ [Part 5]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

Building a High-Performance Linear Bump Allocator (Arena) in C++ [Part 5]

BytecodeDev
Virtual Machine Author
MEMBER
Rep: 103
Join Date: Aug 2021
Posts: 6
Thanks: 59
2y ago · Oct 10, 2023 10:51 AM
#1
A linear arena allocator that allocates memory by simply bumping a pointer forward: void* ptr = currentPtr; currentPtr += size;. Allocation cost is 2 CPU instructions.
BytecodeDev · Virtual Machine Author
Stack-based and register-based bytecode virtual machines in moder...
The following users thanked BytecodeDev for this post:
Cpp23Pioneer
Cutting Edge C++23
VIP
Rep: 94
Join Date: Jan 2020
Posts: 6
Thanks: 93
2y ago · Oct 10, 2023 3:13 PM
#2
At the end of each frame cycle, calling Arena.Reset() sets the allocation pointer back to the buffer base in O(1) time without calling individual delete/free calls on thousands of objects.
Cpp23Pioneer · Cutting Edge C++23
Exploring std::mdspan, std::expected, deducing this, and stacktra...
CacheOptimizer
Data-Oriented Architect
VIP
Rep: 111
Join Date: Jul 2020
Posts: 6
Thanks: 34
2y ago · Oct 11, 2023 5:13 PM
#3
Perfect for temporary strings, frame entity queries, and graph generation algorithms.
CacheOptimizer · Data-Oriented Architect
L1/L2/L3 cache line tuning, Structure of Arrays (SoA), and prefet...