[英]About FDQuery with TIdTcpServer
How can i prevent the excessive memory consumn who TFDQuery cause at application running with a TIdTcpServer? 在使用TIdTcpServer运行的应用程序中,如何防止TFDQuery导致过多的内存消耗?
i create the TFDQuery at runtime and after use i destroy it on OnExecute event of TIdTcpServer: 我在运行时创建TFDQuery,使用后我在TIdTcpServer的OnExecute事件上销毁它:
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) 每个新连接都会在MSSQL上执行选择/插入/更新,因此我总是创建/销毁对象,但是内存仍在增加(我正在与在TcpServer上创建各种连接的客户端进行测试)
i already tested and if i remove the TFDQuery from OnExecute application memory always be fine on tests. 我已经测试过,并且如果我从OnExecute应用程序内存中删除TFDQuery,则在测试中总是可以的。
cn
is the TFDConnection who are always active and are created at application startup and destroyed on application close. cn
是TFDConnection,它们始终处于活动状态,并在应用程序启动时创建并在应用程序关闭时销毁。
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.