The system controls the object life cycle automatically. It means that it is not required to destroy objects explicitly. The system destroys any object upon exiting the unit, in which it is described. The system also destroys the objects, which have no external program links. However, unmanaged resources require explicit clearing. The main type of uncontrolled resources are objects serving as an enclosure for OS resources (for example, a file handle), a window handle or a network connection. Even though the garbage collector can track the lifetime of a controlled object encapsulating uncontrolled resources, it has no information on how to clear these resources. When an object encapsulating an uncontrolled resource is created, provide the required code for clearing the uncontrolled resource using the Dispose operator. The Dispose operator enables a developer to explicitly release the memory when an object work is completed.
For details see the subsection:
It is also recommended to get familiar with the following articles in the knowledge base:
See also: