 Formally, resource management (preventing resource leaks) consists of ensuring that a resource is released if and only if it is successfully acquired.This general problem can be abstracted as ""before," "body," and "after"" code, which normally are executed in this order, with the condition that the "after" code is called if and only if the "before" code successfully completes, regardless of whether the "body" code executes successfully or not.This is also known as "execute around" or a "code sandwich," and occurs in various other contexts, such as a temporary change of program state, or tracing entry and exit into a subroutine.