lNet - http client memory leaks on specific response lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Dibo · 2011-05-05 11:03 Hi, I am using TLHTTPClientComponent. I wrote cache manager which store response content in local file and ask server for checking if this content is modified using header "If-None-Match" and Etag. This works fine, server response "hsNotModified" and I know that I have this same content. But if I send in header: "Connection: close" and server response hsNotModified then heaptrc show mi memory leaks: QuoteHeap dump by heaptrc unit 17720 memory blocks allocated : 5472540/5517008 17719 memory blocks freed     : 5471516/5515984 1 unfreed memory blocks : 1024 True heap size : 3702784 True free heap : 3703232 Should be : 3701632 Call trace for block $00007FFFF7F873D0 size 1024   $0000000000793A9A line 2056 of ../lib/lhttp.pp   $0000000000797ABD line 1324 of ../lib/lnet.pp This is in line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i constructor TLHTTPClientSocket.Create;begin  inherited Create;   FCurrentInput := TClientOutput.Create(Self);  ResetDefaults;end;  This happens only if I get "not modified". If content is modified or I use "connection: keep-alive" then is no memory leaks. I am trying write some patch but I can't find place where I should free this object :/ Regards ---------------------------------------------------------------------- ZL · 2011-05-05 13:05 Maybe you get the same bug I reported a while ago: http://bugs.freepascal.org/view.php?id=16741 The problem description is there in the bug report, and I am using a kind of solution, but I do not know if it is the right one (it works for my program) so I didn't post the patch... I didn't use lNet for a while, so I do not know if newest svn versions had some changes regarding this. ---------------------------------------------------------------------- Dibo · 2011-05-05 13:13 Actually your bug was fixed by my patch This one is something else and I can't handle this. ---------------------------------------------------------------------- Dibo · 2011-05-05 14:28 Personally, I think that heaptrc can't detect this object. Because I trace this object and it is added by: TLEventer.AddForFree, and destroyed by: TLEventer.FreeHandles ---------------------------------------------------------------------- Dibo · 2011-05-05 15:04 I prepared example based on HTTP client demo. Just click "Send request". It create file "memory.txt" in executable directory, with heaptrc summary.  Maybe someone can debug this better from me, if not then I report this as heaptrc bug. Demo in attachments ---------------------------------------------------------------------- Almindor · 2011-05-05 18:26 Quote from: Dibo on May 05, 2011, 05:04:47 pmI prepared example based on HTTP client demo. Just click "Send request". It create file "memory.txt" in executable directory, with heaptrc summary.  Maybe someone can debug this better from me, if not then I report this as heaptrc bug. Demo in attachments Thanks, I'll look into it.