How to reduce RAM usage of dedicated server!

We are developing a game where we want to spawn several (hundreds) of dedicated server, each running MMO like game with a few players joined. The CPU usage is really low (<< 1%) on dedicated server, as is the bandwidth with peaks around a few kB/s (I am unsure, maybe this is high as well). Our bottleneck is actually the RAM usage. Dedicated server uses around 100 MB, Task manager actually displays 250 MB but I guess this is due to DLLs that will be shared anyway. In simple maps, the server usage is lower but we want real maps, where the usage is high. I am guessing that has to do with accurate physics representation of meshes that needs to be stored on the server (and we do not need because we are not doing complex traces), and maybe also other resources. Our game is heavily built in blueprints and that maybe also takes a big portion of memory.

Does anyone now if it is possible to reduce RAM usage? I am preparing to profile the dedicated server but it is harder because I cannot execute console commands on it (at least I do not how).

Thanks for any answers or specuations on your part in advance!

The question your are asking is hard to answer, but I go ahead and at least point out some general things about the engine that I have noticed.

When your working with maps, you got to load a lot into memory by default…
Although unreal has the ability to load and unload things… overall its going to need to know a lot about what is going on…
But if you where crazy enough to build a very big map, like a mmo type world of a game where the map is massive… you certainly will need to utilize this ability.
Unreal has a good map splitting tool, but this would be a overkill for a basic game with player maps that where of avg size.

I dont know if unreal server mode is loading all the textures, etc but I bet this would be something that you could control somehow which would give you a lot of memory back if the textures are being loaded.
The Physics engine would need to know about most of the meshes, anything that is needed for gameplay will need to be on the server.

Blueprints are slow, so I would consider converting some of the heavy ones if they are shooting lots of raycast or creating spawned objects… etc in C

Just some ideas, not sure if any of it is useful or not… good luck either way!

I highly recommend the scientific process:

  1. Collect data
  2. Analyze data
  3. Make changes based on data
  4. Goto 1

See this article for details on how to use the memreport tool.

You can inform server that he should launch console command through RPC server function called from client’s player controller.

Try using process explorer to better gauge the resources your server is actually using.
Other than that without having the server or code to Unit Test, reducing the ram usage is nontrivial. However, 100MB for a dedicated game server does not seem that high considering it has load all of its resources.

I thought 100Mb is quite good – we aim for 200Mb for dedicated server memory.

Main focus is to reduce number of assets that have hard references.

For example, your main character blueprint may hold array of possible weapons. Each weapon could be a blueprint with a list of animations, sounds, particles and meshes that are needed while character has that weapon equipped. Dedicated server cooking removes some of the elements (eg sounds and particles) from build, so these wouldn’t use memory, but it is possible that your server doesn’t need meshes nor animations either (because they don’t have root motion) and are needed on the client only.

So, if character blueprint has TArray<AWeapon*> all such weapons with all assets that they refer to will be loaded into memory. If, however, you have TArray<TAssetPtr<AWeapon>> you can then decide when to load it into memory.

If this AWeapon class has code required to execute on dedicated server, then you can have such pointers to assets that are optional, and load them on the client only…

Further reading:

Good luck!

I don’t have a lot of experience in memory management in general but I found the article below to be very enlightening.

Thanks for all the replies. I am already using some of the techniques you mentioned, even though I guess I could improve. For example, we are using TAssetPtr references for all dynamically loaded materials and textures, as well as skeletal models. I guess I should, however, check the exact per-component memory usage and find extensive memory uses.
So I guess 100-200MB for dedicated is not a lot? I mean, the whole World of warcraft server runs on a few gigs and can support really big worlds and many instances. I know that some private servers run on 8 core computers with 16 GBs of RAM and can support up to 5000 players online at the same time. There are many instances running there as well. The server is only using a few MB per players, and we have to use around 40 MB per player if we assume 6 players per instance. I guess this has to do with optimized/low res representation of worlds, but I guess we could do better. Maybe there is other magic involved.

Otherwise, Unreal already optimized a lot on dedicated servers. So textures, materials and particles are not loaded (or at least no streamed). However, meshes get fully loaded but I only need physics representation (bounds). Another part are the blueprints: we are using them heavily and they probably consume a big portion of memory. What I intend to do is wait for Blueprint to C++ feature that will speed up and (hopefully) reduce the size by a bit margin

I am using the remote procedure call from server to start some commands on the server. I was just hoping there is so better method for doing this on the server directly in development build (like run this console command on server).

Thanks for all the memory tools documentation you linked, it proved helpful. I will try to post my findings when I am done optimizing my scene a bit, but I guess whatever I do might be too specific for my project.