RTC Forums
April 29, 2024, 09:55:11 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcHttpClient Memory Leak When Created from a TThread  (Read 3417 times)
DougB
Newbie
*
Posts: 19


« on: September 08, 2014, 10:22:20 PM »

I ran into a memory leak with the RTC components when I create instances of TRtcHttpClient inside another thread.

I've created a very simple project here that reproduces the problem, including the leak report:

http://ge.tt/3LU5Kqu1/v/0

Thanks,
Doug
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 08, 2014, 11:46:20 PM »

The Memory Leak is not a result of creating the components from a background thread. It is a result of preparing a new Request object on the TRtcDataRequest component, but NOT posting the object to the request queue.

In short, the lines in your ClientManager unit, where you are assigning values to properties of the "fRequest.Request" object will silently create a new Request object, which is supposed to be posted to the request queue by calling "Post", but you never do that, which leaves the object unused and results in a memory leak when the component is destroyed.

Commenting out the lines with assignments to fRequest.Request (in case you did not plan on posting a new request), or calling "fRequst.Post;" as the last line in your THttpClient.Create method (if the request object was prepared and should be put into the request queue and posted to the Server) will fix the memory leak.

Best Regards,
Danijel Tkalcec
Logged
DougB
Newbie
*
Posts: 19


« Reply #2 on: September 09, 2014, 12:59:01 AM »

Thanks, that did it!

Doug
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 17 queries.