Recent

Author Topic: lNet - http client memory leaks on specific response  (Read 6109 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
lNet - http client memory leaks on specific response
« on: May 05, 2011, 01:03:47 pm »
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:
Quote
Heap 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][+][-]
  1. constructor TLHTTPClientSocket.Create;
  2. begin
  3.   inherited Create;
  4.  
  5.   FCurrentInput := TClientOutput.Create(Self);
  6.   ResetDefaults;
  7. end;
  8.  
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

  • New Member
  • *
  • Posts: 16
Re: lNet - http client memory leaks on specific response
« Reply #1 on: May 05, 2011, 03:05:02 pm »
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

  • Hero Member
  • *****
  • Posts: 1048
Re: lNet - http client memory leaks on specific response
« Reply #2 on: May 05, 2011, 03:13:17 pm »
Actually your bug was fixed by my patch ;)

This one is something else and I can't handle this.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: lNet - http client memory leaks on specific response
« Reply #3 on: May 05, 2011, 04:28:36 pm »
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

  • Hero Member
  • *****
  • Posts: 1048
Re: lNet - http client memory leaks on specific response
« Reply #4 on: May 05, 2011, 05:04:47 pm »
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

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
Re: lNet - http client memory leaks on specific response
« Reply #5 on: May 05, 2011, 08:26:39 pm »
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

Thanks, I'll look into it.

 

TinyPortal © 2005-2018