Re: Auto cleanup of dynamic array of Trecord.DynamicArray when first is nilled ?



Skybuck Flying wrote:
Hello,

Are dynamic arrays in dynamic array of records automatically cleaned up when dynamic array of records is nilled ?

program Project1;

{$APPTYPE CONSOLE}

uses
SysUtils;

type
Ttest = record
mCode : array of byte;
end;

var
vArray : array of Ttest;

begin
try
SetLength( vArray, 10 );
SetLength( vArray[5].mCode, 5*1024*1024 );

vArray[5].mCode[0] := 6;

readln;

writeln( vArray[5].mCode[0] );

vArray := nil; // auto clean up of code ?

readln;

except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
readln;
end.

It seems like mCode array is automatically cleaned up ?

Bye,
Skybuck.


Dynamic Arrays use the same handler as the strings do.
when you exit the block that declared it, code in the background
is generated to properly clean it up.
It should work fine unless there is something strange you're doing.


http://webpages.charter.net/jamie_5";

.