【发布时间】:2016-03-15 20:47:30
【问题描述】:
我有这个功能
function doHTTPRequest(const AUrl: String): String;
// ------------------------------------------------------------------------
// return the response for a http request
var
aIdHTTP : TIdHTTP;
begin
Result := '';
aIdHTTP := TIdHTTP.Create(nil);
try
aIdHTTP.HandleRedirects := true;
aIdHTTP.RedirectMaximum := 5;
aIdHTTP.ConnectTimeout := 5000;
aIdHTTP.ReadTimeout := 10000;
Result := aIdHTTP.Get(aUrl);
aIdHTTP.Disconnect(false);
if Assigned(aIdHTTP.IOHandler) then
aIdHTTP.IOHandler.InputBuffer.Clear;
finally
if Assigned(aIdHTTP) then FreeAndNil(aIdHTTP);
end;
end;
每次我调用这个函数时,“任务管理器”中的进程都会增加 200 Byte(或多或少)的私有工作集内存。
我哪里错了?
我已经使用了 FastMM 和 AQTime 但没有发现内存泄漏
这是我在任务管理器中看到的一个示例,从begin 到end 内存增加了 200 字节并且它永远不会被释放...
doHTTPRequest
begin = 3.480 KB
end = 3.652 KB
----------------
diff. 184 Byte
doHTTPRequest返回值为html字符串(约20KB)
doHTTPRequest 被TIdHttpServer 调用,如下所示:
procedure TServer.CommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
AResponseInfo.ContentText := doHTTPRequest('http://example.com/foo.html');
end
【问题讨论】:
标签: delphi memory-leaks indy10 idhttp