Technique for cleaning up resources

When you have a method (or thread) that needs to clean up resources on exit, and you have to worry about that method being interrupted, there is a technique where those resources will clean up themselves. In a nutshell, you create a class for the resource, then use an instance of that class in your code. The cleanup code will be in the class’ Destructor so, if the method ends prematurely, the resource will clean itself up.

So there’s a little tip for those who hadn’t thought of it before, but here’s my question:

What the heck is the name of that technique? I simply can’t recall…

finalizer?

Thanks, but I don’t think that was it. It seem to recall it was an acronym or something.

RAII (resource acquisition is initialization) is the term used in C++.

That sounds closer, but I don’t think that’s the term I heard. I’ll hold off making that as the answer in case someone else can come up with it.

(Why do I think I first heard about this from Norman?)

Sure sounds like RAII

I guess that’s it then. Thanks.

For reference:

http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization