Closed PolSpock closed 1 year ago
I should have time to look into this on Wednesday, thanks for reporting!
Should be good now, but please give me a poke if you still have problems with it.
No server crashes anymore! I am so happy, but at the same time, i feel so embarrassed that i couldn't find it myself 😳 some gaps in my knowledge of .NET 😅
Your reproduction steps did 90% of the work for me, saving me so much time. I think you can be proud of that!
Hello,
Main topic
As i explained on this issue https://github.com/sboxgame/issues/issues/4109, i'm using the Facepunch sbox-sdf library for my game, and in the past, i used sbox-csg.
The common point between the 2 that i'm encountering * OUT OF MEMORY! /+/ attempted allocation size: 5000055 error on my sbox-server.exe running on windows dedicated server.
I've decided to investigate myself to spot the error, and i have spotted a crashing out of memory error caused by
BaseNetworkable.OnCallRemoteProcedure
So here's the code i'm talking about: https://github.com/Facepunch/sbox-sdf/blob/main/libsdf/code/SdfWorld.Entity.cs#L114C32-L114C32
In fact, the more time passes by, the more you will increase your memory. And, arrived in a specific usage of memory, which I cannot explain how much and why, your server will run
***** OUT OF MEMORY! *****
You can easily try the issue on my
sandbox
derived game: https://github.com/PolSpock/sbox-memory-leak/tree/main where you just have to spawn someOnCallRemoteProcedureEntity.cs
with the ingame Toolguncode/tools/OnCallRemoteProcedureEntitySpawner.cs
What I've tried
So I've decided on a temporary solution to switch the SDF library
OnCallRemoteProcedure
usage to the more stableINetworkSerializer
API. Yes, the memory will still increase but it doesn't crash your server with of memory exception. And once again I cannot explain why.However, since the SDF update for leaving the default Entity behavior, i haven't been able to [Net] the
ISdfWorldImpl
I have tried so many Network shit on SdfWorld.cs but still unsuccessfully.
The only working behavior I have been able to do is to [Net] a Sdf2DWorld entity, but this creates some replication issues between Client/Server. In fact, the client will not follow correctly some shared behaviour. For example, when i spawn it, it will create 2 separate entities both Server and Client, and when i delete one, only the serverside is deleted. Etc.
So if you could please bring me some answers i will be happy 🙏
Regards