feat(Memory): add Memory subsystem with BudgetResource, Arena, and BlockPool (S-MEMORY-02..04)

This commit is contained in:
faumaray committed 2026-11-24 02:49:28 +03:00
1 parent 4227348051
commit 4d48f2a8f2
11 files changed
+1306

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
#include <Void/Memory/Arena.hpp>
#include <Void/Memory/BlockPool.hpp>
#include <Void/Memory/BudgetResource.hpp>
int main()
{
Void::Memory::BudgetResource budget{1024 * 1024};
Void::Memory::Arena arena{65536, 4096, budget};
Void::Memory::BlockPool pool{64, 16, 16, 4096, 8, budget};
auto mem = arena.try_allocate(128, 32);
auto blk = pool.try_allocate();
if (!mem || !blk) {
return 1;
}
pool.deallocate(*blk);
(void)pool.trim_idle();
return arena.reset().has_value() ? 0 : 1;
}