Dynamic Variables You can create dynamic variables by calling the
GetMem
or
New
procedure. Such variables are allocated on the
heap and are not managed automatically. Once you create one, it is your responsibility ultimately to free the variable's
memory; use
FreeMem
to destroy variables created by
GetMem
and
Dispose
to destroy variables created by
New
. Other standard routines that operate on dynamic variables include
ReallocMem
,
AllocMem
,
Initialize
,
Finalize
,
StrAlloc
, and
StrDispose
.
Long strings, wide strings, dynamic arrays, variants, and interfaces are also heap-allocated dynamic variables, but
their memory is managed automatically.