Is a dynamic array automatically deallocated when it goes out of scope?

Azarien picture Azarien · Jun 24, 2010 · Viewed 13k times · Source

in this example

procedure foobar;
var tab:array of integer;
begin
  setlength(tab,10);
end;

is the array destroyed or the memory is leaking?

Answer

Andreas Rejbrand picture Andreas Rejbrand · Jun 24, 2010

The memory is freed. (That is, no memory leak!)