[fpc-pascal] why dynamic array created in constructor not automatically free in destructor
Dennis Poon
dennis at avidsoft.com.hk
Thu Aug 7 10:21:19 CEST 2014
I have a class like;
------------
TMyClass=class
public
ar : array of integer;
constructor Create;
destructor destroy;override;
end;
TMyClass.Create;
begin
inherited;
SetLength(ar, 100);
end;
TMyClass.Destroy;
begin
ar := nil;//<--- this is needed otherwise a memory leak is reported!
inherited;
end;
----------
I would expect the compiler would automatically insert this ar := nil on
my behalf because it seems like it does it for strings.
Am I missing some compiler directives?
Dennis
More information about the fpc-pascal
mailing list