Tuesday, 26 May 2020
  5 Replies
  1K Visits
  Subscribe
Hello,
In the unit sgcWebSocket_Client I found a strange behaviour at line 932 where the field FWSConnection is set to nil.
This creates a memory leak in the destroy method of the inherited TsgcWSClient where you do this:

destructor TsgcWSClient.Destroy;
begin
Active := False;
DoClear;
sgcFree(FQueueOptions);
sgcFree(FLoadBalancer);
sgcFree(FWSConnection);
sgcFree(FAuthentication);
sgcFree(FOptions);
sgcFree(FProxy);
inherited;
end;

As the FreeAndNil function check if FWSConnection is nil then it destroy nothing.

If I comment the line 932 then everything works fine and no more memory leaks (more or less, but I'll try tomorrow). But I don't know what this implies...

This memory leak is a bit confusing inside my big application and it grows memory when it shouldn't. I see my application growing memory with a lot of connections\disconnections.

Thanks in advance,
Eddy