简体   繁体   中英

About FDQuery with TIdTcpServer

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.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM