RAII
Abbreviation · Development
Definitions
Resource Acquisition Is Initialization — a C++ idiom where resource ownership is tied to object lifetime. Resources (memory, file handles, locks) are acquired in a constructor and released in the destructor, guaranteeing cleanup even when exceptions occur. The worst-named best idea in C++.
In plain English: A C++ pattern where opening a resource and cleaning it up are automatic: the moment you create an object it grabs the resource, and the moment it disappears the resource is released.
Example: "With RAII, the mutex lock is released when the guard object goes out of scope — no manual unlock, no forgotten cleanup."