StaticMeshSocket Memory usage / Streaming / GC

Hi!

Quick questions. We have a lot of Socket on static mesh that we only use in the editor for placement and such. We typically have around +12000 StaticMeshSocket (cmd Obj List) when in the game that use ~1.6mb. The memory is not too bad but the number of StaticMeshSocket (that seems to be on uobject per socket) could be more of a concern for the Streaming and Garbage Collect? Or should I ignore that?

cheers

Hi there,

Yes, you are correct that each UStaticMeshSocket is a full UObject, which means that it does count toward your max UObject limit. This also means that it does have an impact on your streaming and garbage collection performance, although I realistically expect this cost to be quite minimal.

The garbage collection cost is more of an additional complexity issue, due to the additional number of objects, more than the raw memory cost. Unless you’re dynamically referencing or instancing them at runtime, it’s likely not going to be a major issue. It’s worth noting that Unreal Engine GC cost also scales with the depth of the hierarchy, and sockets are nested within a UStaticMesh.

But with that being said, if you were looking to remove this performance overhead, I would recommend investigating ways you could strip these sockets out of your project before shipping. Since sockets are serialised with the mesh, you would have to remove these pre-cook. I would look into custom tooling to remove sockets from meshes that are not needed at runtime.

You could look at potentially doing the following:

  • An Editor Utility Widget that batch processes selected assets in the editor (And removes sockets from those selected assets after they are placed). This is a little more manual, though, and may not be feasible depending on whether you need the sockets to persist after an asset is placed in the editor.
  • An automated content audit step before the build cooking, and removing all sockets from specific meshes at this stage.

Your other option is to look at adding your own custom engine logic, which enables you to wrap static mesh sockets in an #if WITH_EDITORONLY_DATA macro or some sort of custom “socket editor-only” checkbox for your designers to toggle. This would require a larger engineering effort to implement, though.

Let me know if you have any follow-up questions.

Regards,

Thomas