There are some types that require special handling in Delphi. They all involve automatic memory management on the part of the compiler.
AnsiStringWideStringVariantandOleVariant- These types all need to get released.
- Interface
- When an interface variable goes out of scope, Delphi checks whether it
is assigned. If it is, then Delphi calls the interface’s
_Releasemethod. - Dynamic array
- Dynamic arrays are like
AnsiStrings in that they are reference-counted, and empty arrays are represented internally by anilpointer. When a dynamic-array variable goes out of scope, the compiler inserts code to check the current value of the array, so if the array reference is non-nil, its reference count gets decremented, and if the reference count reaches zero, then the array is freed. If it is an array of a type that would need special treatment under the rules in this article, then the array’s elements are processed before the array itself gets freed. - Array and record
- If an array or record contains any elements or fields of any types in this list, including other arrays and records, then the special compiler consideration is applied recursively.