RTC Forums

Subscription => Support => Topic started by: DougB on September 08, 2014, 10:22:20 PM



Title: TRtcHttpClient Memory Leak When Created from a TThread
Post by: DougB 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


Title: Re: TRtcHttpClient Memory Leak When Created from a TThread
Post by: D.Tkalcec (RTC) 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


Title: Re: TRtcHttpClient Memory Leak When Created from a TThread
Post by: DougB on September 09, 2014, 12:59:01 AM
Thanks, that did it!

Doug