DestroySession causes out of memory in dedicated server

Hello, I recently managed to implement the steam onlinesubsystem, being able to create a dedicated server and let client find and join it. However when the game ends I tried to call DestroySession with corresponding session name, it immediately shows a warning about memory is not enough and later it says run out of memory when allocating about 48G spaces.

I create and start this session in C++ and none of these returns failure, except a warning “sessionflags:xxx overflows steam setgametags call”, but the game runs normally in both server and client. In addition the destroysession works well if I use onlinesubsystemnulll. There is really little discussion about this.

Hey swfly,
I encountered the same problem just now, did you ever find the cause of this problem?
best regards,

Hi , I totally forget what I did back to then… probably I just adopted the AdvancedSession or some plugin. Sorry it was too long ago… Good luck!

Oh bugger, thanks for the fast reply anyway!

On friday I found out that the crash happens in the callstack of FOnlineVoiceSteam::RemoveAllRemoteTalkers(). When trying to call “RemoteTalkers.Empty(MaxRemoteTalkers);” (so emptying a TArray).
Does this trigger any memories for you? ^^’

Great job man! Congratulations on a working solution!

Disclaimer: This answer regards Unreal Engine version 4.20.3

So after some debugging I found the problem and the solution:

When using the Steam Subsystem and calling DestroySession the method FOnlineVoiceSteam::RemoveAllRemoteTalkers() is called.
This is responsible to remove all data stored from remote voice talkers, even if you have the system deactivated in the ini file or never even have any connected.

The problem is in the following line: RemoteTalkers.Empty(MaxRemoteTalkers);

This tries to Empty() the TArray of remote talkers, but leave enough allocated space for the the possible maximum of remote talker data. What happens is: On dedicated servers the Init() function of FOnlineVoiceSteam is never called and therefore MaxRemoteTalkers is not initialized. The memory (on debug and dev builds) is filled with 0xcd and when translating that to numbers its something along the lines of 48 GB. (That’s where that number comes from)

So the solution for me was:

Initialize the system, even on dedicated servers. (This means changing the source code of the engine) and recompiling. I basically copied the GetVoiceInterface() method from 4.21 Source as it tries to initialize the system on every GetVoiceInterface() as long as its not initalized.

Another solution would be: Upgrade to UE 4.21, it seems to be fixed there.

I hope this helps anyone!
kind regards,