Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-03

reference counting of multi-dimensional array

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

If I have this:

var
  a2: array of array of Integer;
  i, j: Integer;
begin
  SetLength(a2, 3);
  for i := 0 to 2 do begin
    SetLength(a[i], 3);
    for j := 0 to 2 do a[i][j] := 1;
  end;
  a2 := nil; <-- will this free all memory of a[0]...a[2]?
end;

Thanks!

Xiangrong

Jonas Maebe
to Xiangrong Fang
Xiangrong Fang wrote 11 lines
var a2: array of array of Integer; i, j: Integer; begin SetLength(a2, 3); for i := 0 to 2 do begin SetLength(a[i], 3); for j := 0 to 2 do a[i][j] := 1; end; a2 := nil; <-- will this free all memory of a[0]...a[2]? end;

Yes.

Jonas