3 ms·
RAII can help you protect heap memory (and other resources besides memory) because it's more about registering code to run on the end of object lifetimes rather
by monocasa 8y ago
RAII can help you protect heap memory (and other resources besides memory) because it's more about registering code to run on the end of object lifetimes rather than just the memory being deallocated. Alloca isnt really a great option for async flows for instance, to say nothing of file descriptors, or abstract concepts like 'the idea of this mutex being locked'. Alloca is also terrible for memory passed on to other threads obviously..
Albeit most of that is moot when compared to a GCed language like the global discussion.