RAII

Resource acquisition is initialization means holding a resource is a class invariant, and is tied to object lifetime: resource allocation is done during object creation, by the constructor, while resource deallocation is done during object destruction, by the destructor. In other words, resource acquisition must succeed for initialization to succeed. Thus the resource is guaranteed to be held between when initialization finishes and finalization starts and to be held only when the object is alive. Thus if there are no object leaks, there are no resource leaks.
RAII is associated most prominently with C++ where it originated, but also Rust. RAII is generally pronounced as an initialism, sometimes pronounced as "R, A, double I".