[fpc-pascal] Objects, open arrays and memory leaks
Santiago A.
svaa at ciberpiula.net
Thu Jan 14 13:10:15 CET 2016
Hello:
I'm using Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
I'm getting memory leaks (on winXP and Linux) . I have tracked to this.
(Note: they are objects, not classes)
type
TArray=object
InnerList:array of integer;
constructor Init;
end;
constructor TArray.Init;
begin
SetLength(InnerList,10);
end;
procedure test;
var
obj:TArray;
begin
obj.init;
obj.init;
end;
When I call twice the constructor "init" there is a memory leak. The
open array of first init is not freed;
init just sets the length of an open array to 10. I mean, no pointer or
object created.
I know open array are implemented pointers but I supposed that runtime
would take care of it, so I was using the constructor to clear object
and start from scratch.
What I am missing?
--
Saludos
Santiago A.
More information about the fpc-pascal
mailing list