Having an Olympia server and several other services (executables) which are ‘monitored’ by the Olympia service.
One of the services is a ‘broadcast’ service to broadcast events to all users despite the application they use nor the service to which they connect.
So, the client requests something from the productionservice, the productionservice requests a broadcast from the broadcastservice and the broadcastservice ‘broadcasts’ an event. (extract of the code below)
When I stop the broadcast-executable, an ROSession is leaked… I can’t solve it…
Broadcastservice has requiresession false, the productionservice has requiresession true.
Regards,
Filip
procedure TBroadCastService.SendToAll(const Message: TBroadCast);
var
sList: TStringList;
saService: ServiceApplication; //enum of applications in use
begin
sList := TStringList.Create;
try
for saService := Low(ServiceApplication) to High(ServiceApplication) do
if saService <> saUnknown then
begin
TROOlympiaSessionManager(SessionManager).ApplicationID := saService.ID;
SessionManager.GetAllSessions(sList);
end;
Send(Message, sList);
finally
sList.Free;
end;
end;
procedure TBroadCastService.Send(const aBroadCast: TBroadCast;
const Sessions: TStrings);
var
anEvent: IBroadCastEvent_Writer;
begin
anEvent := (EventRepository as IBroadCastEvent_Writer);
anEvent.SessionList.Clear;
anEvent.SessionList.AddStrings(Sessions);
anEvent.ExcludeSessionList := False;
anEvent.ExcludeSender := True;
// register all clients
for iCnt := 0 to anEvent.SessionList.Count - 1 do
RegisterEventClient(AnsiString(anEvent.SessionList.Strings[iCnt]), EID_BroadCastEvent);
anEvent.OnBroadCast(ClientID, aBroadCast);
end;
It’s not easy to isolate the necessary code…
Would this be helpful? If not I’ll try to create a testcase…
As you can see the SendToAll method is called, then the Send (as shown in the code above).
It looks like after the session had been created, it’s never freed, not even when I call DestroySession when I close the application.
from your screenshot, it seems that after changing ApplicationID, SessionManager can’t find session and created a new one.
as a result, existing instance of ROSession could be overridden with newly created so memory leak may appear
also check this case: the session should be deleted with the same ApplicationID that was used at creating session.
Indeed, that’s the issue. The sessionmanager can’t find the (newly) created session, because it is never ‘registered’ with the Olympia server.
The OnSessionCreated event is fired, but the session ID never appears in de database (Olympia with SQL Server).
Even if I do a GetAllSessions, the session ID is not in the list.
Could it be that RequireSession := False is the cause that the SessionID is not registered in de DB (and eventually causes the memory leak)?
I attached a full logging from starting the service - executing a SendToAll - and shutting down. As you can see, the session is created but can’t be found.
I created a the session in the OnActivate of the BroadCastService (to test - as shown in the log).
There is no login involved in that particular situation. A client logs in due to a call to the production service (OnLoginNeeded). Due to that call the production service ‘needs’ to broadcast an event. So, the production service becomes a client of the broadcast service, but never logs in.
> Client application --> Production service --> Login service --> Olympia service
> | |
> | |
> |<---> BroadCast service <---------------->|