3.9 Managed types

By default, pascal types are unmanaged. That means that variables must be explicitly initialized, finalized, memory allocated and so on. However, in Object Pascal, several types are managed, which means that the compiler initializes and finalizes variables of this type: this is necessary, for instance for reference counted data types.

The following types are managed:

AnsiString
They are initialized to Nil.
UnicodeString
They are initialized to Nil.
WideString
They are initialized to Nil.
Interface
They are initialized to Nil.
Dynamic arrays
They are initialized to Nil.
Variants
They are initialized to the empty value (VarIsEmpty will return True).

And any record or array whose elements contain managed types.

Class instances containing managed types are also initialized, but the class instance pointer itself is not.

Variables of managed types will also be finalized: this means, in general, that their reference count will be decreased at the latest at the end of the current scope.

Remark Note that no assumption should be made about the exact time of this finalization. All that is guaranteed that they are finalized when they go out of scope.