Possible Memory leak in TROHttpApiSession

Hello,

I experimented some memory leak with an delphi custom server every login.

Memory leak is reported as

I use DataAbstract 10.0.0.1559 Delphi Version.

I can’t figure out if the problem is with my code or the library!

A memory block has been leaked. The size is: 28

This block was allocated by thread 0x1B50, and the stack trace (return addresses) at the time was:
00569776 [FastMM5.pas][FastMM5][FastMM_DebugGetMem$qqri][7821]
0054771A [System.pas][System][@GetMem$qqri][4949]
0054B17B [System.pas][System][TObject.NewInstance][18306]
0054B87A [System.pas][System][@ClassCreate$qqrpvzc][19635]
011A50C4 [uROHttpApiSession.pas][uROHttpApiSession][TROHttpApiSession.Create]
005880E9 [System.SysUtils.pas][System.SysUtils][Sysutils.TMultiReadExclusiveWriteSynchronizer.UnblockOneWriter][27733]
00F0CFEF [uROIndyHTTPServer.pas][uROIndyHTTPServer][TIndyHTTPTransport.GetHeaders$qqrx20System.UnicodeString][220]
011A5E9F [uROHttpApiSimpleAuthenticationManager.pas][uROHttpApiSimpleAuthenticationManager][TROHttpApiSimpleAuthenticationManager.ReadAuthenticationInfo][78]
00CCE730 [uROServer.pas][uROServer][TROClassFactoryList.GetClassFactoryByInterfaceName$qqrx20System.UnicodeString][423]
00547736 [System.pas][System][@FreeMem$qqrpv][4997]
011BF432 [uROHttpApiDispatcher.pas][uROHttpApiDispatcher][TROHttpApiDispatcher.InvokeServiceMethod][258]
011BFA4E [uROHttpApiDispatcher.pas][uROHttpApiDispatcher][TROHttpApiDispatcher.Process][329]
00EEB45A [uROCustomHTTPServer.pas][uROCustomHTTPServer][TROCustomHTTPServer.HandleExtendedDispatchers][340]
00EEC68F [uROBaseHTTPServer.pas][uROBaseHTTPServer][TROBaseHTTPServer.ProcessRequest][226]
00F0D861 [uROIndyHTTPServer.pas][uROIndyHTTPServer][TROIndyHTTPServer.InternalServerCommandGet][497]
0056821E [FastMM5.pas][FastMM5][FastMM_FreeMem_FreeDebugBlock$qqrpv][4227]
00EE3212 [IdCustomHTTPServer.pas][IdCustomHTTPServer][TIdCustomHTTPServer.DoCommandGet][1013]
00EE445D [IdCustomHTTPServer.pas][IdCustomHTTPServer][TIdCustomHTTPServer.DoExecute][1468]
00EB084C [IdContext.pas][IdContext][TIdContext.Run][185]
00EAF235 [IdTask.pas][IdTask][TIdTask.DoRun][136]

The block is currently used for an object of class: uROHttpApiSession.TROHttpApiSession

The allocation number is: 865580

Hi,

in some cases when ClientToken is empty, it is possible.

try to update uROHttpApiDispatcher.pas as

procedure TROHttpApiDispatcher.InvokeServiceMethod(aTransport: IROHTTPTransport; aRequest: IROHttpRequest;
  aResponse: IROHttpResponse; aRequestData, aResponseData: TStream);
...
      l_classFactory := GetClassFactory(l_jsonMessage.InterfaceName);
      try
        try //<<<<<< add this line
...
          l_session := TROHttpApiSession.Create('', EmptyGUID);
        try  //<<<<<<<< comment this `try`
...
        finally
          FreeOrDisposeOf(l_session);
        end;
      finally

and retest

1 Like

Logged as bugs://D19359.

bugs://D19359 was closed as fixed.