You are not logged in.
Pages: 1
Hi ab,
It seems like that,I find the memory leak for the Class named TAutoFree.
when I use the TAutoFree.Create(xxx,XXXClass.Create) in a procedure or a function within a loop code,it will be a memory leak reported by FastMM4.
I encapsulated an internal procedure/function within a procedure or a function,and invoke it within a loop,for example,
function TFrmHost.LoadNetworkConfigFileAndConnectToServer: Boolean;
var
index, retryCount: Integer;
errorMsg, hintMsg: string;
encrptionKey, serverAddress, serverPort, wsPort, rootName: string;
function CheckConnectToServer(): Boolean;
var
fClient: TSQLRestClientURI;
fModel: TSQLModel;
begin
TAutoFree.One(fModel, TSQLModel.Create([], rootName));
TAutoFree.One(fClient, TSQLHttpClient.Create(serverAddress, serverPort, fModel));
Result := fClient.ServerTimeStampSynchronize;
end;
begin
Result := False;
retryCount := 5;
for index := 1 to retryCount do
begin
Result := CheckConnectToServer;
end;
// 尝试次数达到最多仍然无法联网
if not Result then
begin
ShowError('无法联网,请检查网络连接或服务器是否正常启用,稍后再试!', '发生错误');
end;
end;
if I use TAutoFree.Create(fModel, TSQLModel.Create([], rootName)); instead of TAutoFree.One(fModel, TSQLModel.Create([], rootName));
the FastMM4 will give a memory leak report for TAutoFree,but when I use TAutoFree.One(fModel, TSQLModel.Create([], rootName));
it is fine.
Can you tell me the reason ?
Offline
thanks.get it.
Offline
Pages: 1