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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

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

ClangTidyFan
Modern Code Quality
MEMBER
Rep: 94
Join Date: Oct 2023
Posts: 6
Thanks: 16
2y ago · Oct 19, 2023 3:51 PM
#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.
ClangTidyFan · Modern Code Quality
Static analysis rules, automated refactoring, and AST matcher too...
The following users thanked ClangTidyFan for this post:
FiberRunner
User-Mode Scheduling
MEMBER
Rep: 104
Join Date: Mar 2022
Posts: 6
Thanks: 15
2y ago · Oct 19, 2023 7:06 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.
FiberRunner · User-Mode Scheduling
Fiber context switching, cooperative multitasking, and green thre...
AtomicFences
Memory Consistency
MEMBER
Rep: 419
Join Date: Nov 2024
Posts: 6
Thanks: 80
2y ago · Oct 19, 2023 9:06 PM
#3
Perfect for temporary strings, frame entity queries, and graph generation algorithms.
AtomicFences · Memory Consistency
Hardware fence instructions, Store-Load reordering, and Peterson ...