#1 2019-06-11 20:19:05

Shadownildo
Member
From: Brazil
Registered: 2018-10-10
Posts: 36

Memory Leaking using TDDDRepositoryRestFactory in the Server Side

Hello Again, (Time for Multiple Posts big_smile)

So, We are consuming a Interface-Service, as Client-to-Server and Server-To-Self,In the Client-To-Server we don't have a memory Leak, and in the server-to-Self side It Works Perfectly!, BUT, i'm having some trouble with Memory Leak in the Server side with this TDDDRepositoryRestFactory, Sorry if the Code is big , if so i will put in a pastebin!

  ffactory := TDDDRepositoryRestFactory.Create(FServer); 
  FServer.ServiceContainer.InjectResolver([ffactory]);
  FServer.Services.Resolve(IDomSaleQuery, cmd);
  try
    Result := False;
    if cmd.SelectAll = CqrsSuccess then
    begin
      cmd.GetAll(Sale);
      Result := True;
    end;

  finally
   ffactory := nil;
   ffactory.free;
  end;    

and we think it might be the Repo Fault, but we didn't find the reason, any suggestion for what could be??

function TRepoVenda.GetAll(out aAllAggregate: TVendas): TCQRSResult;
begin
 Result:=  ORMGetAllAggregates(aAllAggregate);
end;
function TRepoVenda.SelectAll: TCQRSResult;
begin
  Result := ORMSelectAll('',[]);
end;           

Last edited by Shadownildo (2019-06-13 11:41:10)

Offline

#2 2019-06-11 20:39:52

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Memory Leaking using TDDDRepositoryRestFactory in the Server Side

Correct the order of these lines:

  finally
   ffactory.free; //first
   ffactory := nil; //second
  end;   

Offline

#3 2019-06-13 13:01:09

Shadownildo
Member
From: Brazil
Registered: 2018-10-10
Posts: 36

Re: Memory Leaking using TDDDRepositoryRestFactory in the Server Side

jaclas wrote:

Correct the order of these lines:

  finally
   ffactory.free; //first
   ffactory := nil; //second
  end;   

Thank you For the Answer!

But ths not solve the problem sad , we are Studying the RegressionTests in dddInfraRepoUser, and thinking how manage the Memory... What happen is ,

We have a ClientDriven Service that >
Connect To the Server >
And Inside this Service, we Start Another Connection With the Own Server that Define and Call's Other Service .

function TVendaService.Include(const DadosVenda: TVenda): boolean; // This is the ClientDriven Service
var
  cmd: IDomSaleCommand;
  ffactory: TRepoSaleFactory;
begin
  ffactory := TDDDRepositoryRestFactory.Create(FServer); 
  FServer.ServiceContainer.InjectResolver([ffactory]);
  FServer.Services.Resolve(IDomSaleQuery, cmd); // This is the Inside Service that is a ICQRSService 

When we Free the ClientDriven Service, Clean the Client > Server Memory and it's OK, But, The Inside Service that is a ICQRSService ,Remains in the Memory, and Only gone if we Free the RestServer like is done in the RegressionTests in dddInfraRepoUser.pas, But in a real Scenario we can't Free the RestServer Connection after using one service hmm.

Offline

Board footer

Powered by FluxBB