Random Access Memory is what you buy when you don’t know what your program will do next.
Until recently, alternative tiers of memory with vastly different latency characteristics were largely speculative. Then DRAM got expensive. CXL memory pools, far memory, even high bandwidth flash moved from blips to serious contenders. C++ has grown its vocabulary for ownership (smart pointers) and lifetimes (RAII); but intelligent memory tiering, specifically object residency, is a word we don’t natively have.
Attempts have been made to solve this issue at an OS-level (Meta’s TPP), or even a compiler/runtime level (OBASE) but they approach the problem transparently by design. And thus…blind by design. You can improve tiered object locality with clever placement within pages, but all these methods are structurally incapable of predicting intent. What if the power was in the developer’s hands?
With reflection (P2996) and annotations (P3394), C++26 finally lets us extend the vocabulary ourselves. Game developers have deeply understood smart data grouping for decades, but much of the work is locked behind game engines; not suitable for general application development. [[likely]] and [[unlikely]] hint hot and cold paths, but the future of high-performance development hints at general purpose object residency to tier-aware allocators.
This talk introduces an open-source C++26 residency library, demonstrating capabilities against current, and even (simulated) future hardware. The pieces are in place for C++ to create durable abstractions for object residency; with the flexibility to accommodate memory tiers that have not been invented yet!