Access violation after stress test

I have a problem where, after a while the server stops working and then all requests are answered with Access Violation. There are no memory leaks in my code. Any idea what can it be?

The line 123 (see call stack) is:

procedure Create_ConcertService(out anInstance: IInterface);
begin
  anInstance := TConcertService.Create(nil); // <<--- line 23
end;

Here is the call stack:

EAccessViolation: Access violation at address 0042A0F4 in module 'ConcertSOAPv3.exe'. Read of address 00000078
----------------------------
[0042A0F4] System.SysUtils.CompareText + $1C
[0067C68B] Vcl.Forms.FindGlobalComponent + $67
[004C8DE9] System.Classes.FindGlobalComponent + $3D
[004C8E14] System.Classes.IsUniqueGlobalComponentName + $18
[004DC86A] System.Classes.FindUniqueName + $3E
[004DD068] System.Classes.TReader.ReadValue + $8
[004DAB09] System.Classes.TReader.NextValue + $5
[004DC9CF] System.Classes.TReader.ReadRootComponent + $13B
[004D818F] System.Classes.TFiler.Create + $4B
[004D6B8E] System.Classes.TStream.ReadComponent + $32
[004C8E7D] System.Classes.InternalReadComponentRes + $5D
[004CFBA3] System.Classes.InitComponent + $5F
[004CFC31] System.Classes.InitInheritedComponent + $61
[004EAB45] System.Classes.TDataModule.Create + $75
[0040A077] System.@ClassCreate + $7
[00CC33C5] uRORemoteDataModule.TRORemoteDataModule.Create (Line 216, "uRORemoteDataModule.pas" + 2) + $4
[00ECEC7F] ConcertService_Impl.Create_ConcertService (Line 123, "ConcertService_Impl.pas" + 1) + $9
[00CFD1C0] uROServer.TROClassFactory.CreateInstance (Line 1644, "uROServer.pas" + 6) + $7
[00CFB808] uROServer.TROInvoker.CustomHandleMessage (Line 921, "uROServer.pas" + 12) + $1F
[00CFBA56] uROServer.TROInvoker.HandleMessage (Line 967, "uROServer.pas" + 1) + $A
[00CFAFCF] uROServer.MainProcessMessage (Line 719, "uROServer.pas" + 113) + $24
[00CFC3ED] uROServer.TROMessageDispatcher.ProcessMessage (Line 1156, "uROServer.pas" + 2) + $14
[00CFCED7] uROServer.TROServer.IntDispatchMessage (Line 1549, "uROServer.pas" + 27) + $15
[004D5599] System.Classes.TStream.GetSize + $3D
[00D2CB41] uROBaseHTTPServer.TROBaseHTTPServer.ProcessRequest (Line 238, "uROBaseHTTPServer.pas" + 85) + $17
[00D2EACF] uROIndyHTTPServer.TROIndyHTTPServer.InternalServerCommandGet (Line 468, "uROIndyHTTPServer.pas" + 43) + $19
[00D24ECE] IdCustomHTTPServer.TIdCustomHTTPServer.DoCommandGet + $1A
[00D25F02] IdCustomHTTPServer.TIdCustomHTTPServer.DoExecute + $6A2
[00B1E1FB] IdContext.TIdContext.Run + $F
[00B1CD6E] IdTask.TIdTask.DoRun + $2
[00B22506] IdThread.TIdThreadWithTask.Run + $6
[00B21E25] IdThread.TIdThread.Execute + $F5
[004E7415] System.Classes.ThreadProc + $49
[0040B820] System.ThreadWrapper + $28

Hi,

it is failed at creating _Impl forms.
it is weird error and something is happened in delphi’s standard library

What I can suggest - try to change class factory.
Per Request Class Factory is used by default.
Try to change it to Pooled Class Factory.

depended of Code-First or RODL mode, it can be:

[ROPooledClassFactoryAttribute(PoolSize)]

or

fClassFactory := TROPooledClassFactory.Create('PooledService', 
                   Create_PooledService, TPooledService_Invoker, PoolSize);

See the Class Factories sample for more details,

Is there a step by step tutorial on how to change my code to a Pooled Class Factory? I see the examples, but my project is pretty big, not sure where and what to change…

Or do I just change from

fClassFactory_ConcertService := TROClassFactory.Create(__ServiceName, Create_ConcertService, TConcertService_Invoker);

to

fClassFactory_ConcertService := TROPooledClassFactory.Create(__ServiceName, Create_ConcertService, TConcertService_Invoker, 20);

and that’s it?

Yes, that is it.
Note: you can have 20 simultaneous clients only.

1 Like