Memory efficiency, only when needed
The Guardian uses lazy allocation to be memory-efficient. Memory is only allocated when it's actually used.
#include <guardian/memory/lazy.hpp>
using namespace guardian::memory;
LazyStack<int> stack;
// Before: No memory allocated
std::cout << stack.size(); // 0
// After first push: Memory is allocated
stack.push(1); // 🔷 LazyStack allocated
stack.push(2);
stack.push(3);
std::cout << stack.size(); // 3
| Operation | Without Lazy | With Lazy |
|---|---|---|
| Empty VM | ~24 bytes | 0 bytes |
| Startup | Allocates stack | No allocation |