TROArray as var to a service method mem leak in delphi

hi, i’m passing a TROArray to a service function (.net RO server) as var from a delphi app…
now it seems that RO isn’t taking care of the lifetime of that array
the array that is passed isn’t freed and the array after the function is a new instance it seems…

so how do i manage the lifecycle of both arrays in delphi?
(or am i missing something?)

tia,
Marc

Hi,

For var variable you should release both objects, like:

var
  l_in: TROArray;
  l_out: TROArray;
..
  l_in := create_array;
  try
    l_out := l_in;
    fService.Method(l_out);
    // do something with l_out
    l_out.Free;
  finally
    l_in.Free;
  end;

We don’t free input variable automatically because you can lose some important data
this decision should be taken by developer.

ok that’s what i’m doing now…