Overhead of UObject

Hey guys,

Quick question, does anyone know the overhead amount of a base class UObject? I’m deciding for something if I could just extend that to make it easier to get into the game, or if I need to make a custom class with less overhead. There will be a max of a few hundred in a single map (non-instantized), but they also do not load/have a mesh or physics. They would just be position points essentially.

Thanks!

1 Like

Unfortunately I can’t give metrics on the overhead, but if they just need to hold a small amount of data, you can always go with a custom struct, whose overhead should be orders of magnitude less than UObject.
You can also then still have functions on the objects as well.

The overhead is irrelevant, if you need something to be a UObject then make it so, if not don’t. If it’s not exposed to the editor in any way it probably doesn’t need to be a UObject.

Did you try doing a sizeof(My-UObject-Subclass)? I don’t feel like checking myself but it shouldn’t take too much time. I’d be a lot more concerned about performance if you’re going to spawning a whole ton. You know, things like will there be a huge spike if I spawn a hundred in a single frame? Do I need to spread the allocations over multiple frames? Am I making a multiplayer game (If so, I’d be concerned bout network replication as well)

Premature optimization is premature…

Our levels typically have thousands of Actors and tens of thousands of Objects.