Problems using TDALocalDataAdapter

Hello,

On a DataAbtract server in Delphi.
I’m having memory deallocation problems when using TDALocalDataAdapter

Scenario:
In the data service DataService2 I use a TDALocalDataAdapter to access data from the data service DataService1
Things are ok.

If in the data service DataService1 I add a TDALocalDataAdapter component that accesses data from the same data service DataService1, it interferes with the automatic way in which this data service is released and destructor of DataService1 is not called when DataService2 is destroyed.

The current solution I found is to stop using TDALocalDataAdapter to the same data service.

I don’t know if this is a problem in the framework or if I didn’t use TDALocalDataAdapter properly

How should I approach this problem?

I’ve attached two test applications to exemplify this behavior.

TestDataAbstract.zip (172.5 KB)

Hi,

you assign ServiceInstance in OnCreate event:

procedure TDataService.DataAbstractServiceCreate(Sender: TObject);
begin
  dlaMain.ServiceInstance :=  self;
end;

and don’t assign nil. ServiceInstance isn’t a weak reference so you have to clear it manually unless you use ServiceName property as in another service.

try use dlaMain.ServiceInstance := nil; like

function TDataService.GetEmployee: ROUTF8String;
var
  vDataSet: IDADataset;
begin
  vDataSet := Schema.NewDataset(Connection, 'EMPLOYEE');
  try
    Result := DatasetToJson(vDataSet);
  finally
    vDataSet := nil;
    dlaMain.ServiceInstance := nil; //<<<<<<<<<<<<<<
  end;
end;