Do I need to worry about freeing collections in TRoComplexType?

Hi

I created some classes (example below) and I am a little bit confused if I have to free embedded collections in TRoComplexType.
I am using Delphi Alexandria.


TResultProc = class(TRoComplexType)
     private
        Fbool: boolean;
        FSomeError: string;
     published
        property someError: string read FSomeError write FSomeError;
        property withErrors: boolean read FwithErrors write FwithErrors;
  end;

  TResultProcCollection = TRoArray<TResultProc>;

  TOverallCollection = class(TRoComplexType)
    private
      FResultProc: TResultProcCollection;
      FErrorDuringProc: string;
    published
      property resultproc: TResultProcCollection read FResultProc write FResultProc;
      property ErrorDuringProc: string read FErrorDuringProc write FErrorDuringProc;
  end;

I return TOverallCollection in a WebService:

[ROServiceMethod]
    [ROCustom('HttpApiPath','/proc')]
    [ROCustom('HttpApiMethod','POST')]
    function proc(somePars: string ): TOverallCollection;

....
begin
  try
    result := TOverallCollection.Create;
    result.resultProc := proc( somePars ); // returns a TResultProcCollection
    result. ErrorDuringProc := '';

  except
    on E: Exception do begin
        
        result.ErrorDuringProc := e.Message;
    end;
  end;

My question is if I need to free (create a constructor/destructor) in TOverallCollection in order to free TResultProcCollection.

Best regards

Hi,

all returned (var, out, result) objects will be destroyed automatically after they are sent by server side.

1 Like

Wonderful! What a marvelous piece of software is Remoting SDK! So simple to use.