Memory leak when executing remote command from the client

Hi there,

using Delphi XE5, I always have the “ReportMemoryLeaksOnShutdown” option set to true in debug mode.
When executing the following code,

function TServiceRegister.Application: Integer;
var
  lArr  : DataParameterArray;
  rc    : TDARemoteCommand;
 begin
  result := -1;

  rc := GetRemoteCommand;
  rc.Execute('RegisterApplication', ['name', 'id_application'], ['Test', result]);
   lArr   := DataParameterArray(rc.ExecuteCall.Params.FindParam(rc.ExecuteCall.IncomingParametersParameter).AsComplexType);
  result := DataParameter(lArr.Search('Name', 'id_application')).Value;
end;

I get the following memory leak when closing the application :

Being definitely new to RemObjects and DataAbstract, I guess that maybe I am doing things wrong and there is a better (simpler) way to achieve this trivial task…
However, I have to admit that everything works as expected and the remote command is executed! :slight_smile:

Could somebody point me to the right direction?
Thanks in advance.

Kind regards,

Charles

Hello,
Please free lArr variable:

lArr   := DataParameterArray(rc.ExecuteCall.Params.FindParam(rc.ExecuteCall.IncomingParametersParameter).AsComplexType);
result := DataParameter(lArr.Search('Name', 'id_application')).Value;
lArr.Free;

Hi Vovan,

Problem is that I had one single remote command on a data module and freeing the data parameters array was no good idea at all (worked perfectly once than crashed at the next call! :smile:).
However, I now implemented a factory class that returns a remote command on demand and updated my code.
Now freeing the array and the remote command works fine, no memory leaks anymore.
Thanks for your help.

Kind regards,

Charles