It was hard to figure out what was happening on the server in terms of what objects existed in the world, how many there were etc. This information is pretty much critical to optimize memory usage.
So I added a command called "dump".. which dumps a bunch of informa
tion about the world into a folder. This information includes:
This has been really valuable. Unity's GameObjects, ScriptableObjects and Com
ponents use a lot more memory than you'd expect, so the fewer objects we can have the better. The dump command revealed that we had a bunch of sub-objects on the server that weren't really needed.
A simple example would be weapons. The rock has 3 LOD objects. So you have the rock object, then 3 children objects for the LODs. The server doesn't need those children, so if we cull them we have saved 3 game objects. Which is 1,500 game objects when you have 500 rocks weapons in the world.
Now compare that to the Torch, which on the client consists of 11 gameobjects. Or some of the trees, which before optimization had 20+ collider objects.
So we're getting somewhere.. but there still seems to be an unexplained leak. Unfortunately this leak seems to be in normal objects instead of Unity objects. I started making a quick mono profiler to record the GC creating/destroying objects. But then I realised that there apparently isn't a way to detect when an object is destroyed.. so it's going to be tricky.