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.
asked Aug 11 '17 at 02:55 AM in C++ Programming
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, Stefan
answered Jan 11 '19 at 01:22 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here