RAII
Noun
Meaning
RAII (uncountable)
(programming) Initialism of Resource Acquisition Is Initialization (a popular design pattern in object-oriented programming that ties resources to the lifespan of associated objects to prevent resource leakage.)
Synonyms
Anagrams
Examples
However, using RAII correctly is not always easy and has its own pitfalls.
Any class that contain only such RAII objects do not need to define a destructor since the destructors of the RAII objects are called automatically as an object of this class is destroyed.
Java relies mainly on garbage collection, which can reclaim memory, while C++ relies mainly on the Resource Acquisition Is Initialization (RAII) idiom.
Non-deterministic GC is incompatible with RAII based management of non-GCed resources.
Synchronous, coordinated uninitializing and deallocating in C++ thus satisfy the RAII idiom.
The Standard Template Library provides higher-level RAII abstractions (like vector, list and map) to help avoid such errors.