1
I am starting in the world Datasnap and I came across a situation that I can not find solution.
My code is on memory Leak, because I can’t release the objects. if I release the objects the access error violated in result.
function TServerMethods1.Teste(Key: string; ID: Integer): TFDJSONDataSets;
var
Con : TFDConnection;
qry : TFDQuery;
begin
Con:= TFDConnection.Create(nil);
qry:= TFDQuery.Create(nil);
try
qry.Connection:= Con;
qry.SQL.Text:= Format('select id, nome from clientes where id = %d', [ID]);
qry.Open;
Result:= TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, qry);
finally
FreeAndNil(qry);
FreeAndNil(Con);
end;
end;
i need to release the created objects [qry, con] but I’m not getting it.
Thanks for the explanation, I’ll test
– Bruno Cardoso
Junior Moreira, that’s the problem, because Tservermethods1.Testing is on the server, so I would need to release on the server. the way you put it solves the client part, but the server continues with the created object
– Bruno Cardoso