Reputation: 121
How can i prevent the excessive memory consumn who TFDQuery cause at application running with a TIdTcpServer?
i create the TFDQuery at runtime and after use i destroy it on OnExecute event of TIdTcpServer:
Query := TFDQuery.Create(Cn);
Query.Connection := Cn;
Query.SQL.Text := 'update table set column = 0 where ip = :ip';
Query.Params.ParamByName('ip').Value := ip;
Query.ExecSQL;
FreeAndNil(Query);
every new connection perform a select/insert/update at MSSQL, so i always create/destroy the object, but the memory still increasing (i'm testing with an client who create various connections at TcpServer)
i already tested and if i remove the TFDQuery from OnExecute application memory always be fine on tests.
cn
is the TFDConnection who are always active and are created at application startup and destroyed on application close.
Upvotes: 0
Views: 292
Reputation: 121
Solved using this method of creation/destroy at runtime:
with TFDQuery.Create(nil) do
begin
try
Connection := Cn;
SQL.Text := 'update table set column = 0 where ip = :ip';
Params.ParamByName('ip').Value := ip;
ExecSQL;
finally
Free;
end;
end;
Upvotes: 0