There are few questions you must answer yourself first:
-
Do I need replication (networking support on my object). If Yes you want to use actor. You can of course use UObject or even plain C++ class, but you will need to write custom networking replication support for these, and it is by no means easy task to tackle.
-
Does my objects need to be placed in level ? If yes you probably want to use Actor. Creating placeable UObject is easier than networked one, but but I don’t think it’s really worth effort.
-
Do I need garbage collection ? If yes, you can use either UObject or AActor. You can also implement custom class with Garbage Collection enabled. But UObject overhead is not something you should be concerned with.
-
Do I need editor/blueprint support. If yes, use AActor or UObject.
-
If your object, is just simple data store, for properties, then you probably just want to use USTRUCT.
Memory overhead from AActor and UObject is not something you should be really concerned. Single texture will take more memory, than doznes of Actors.
Spawning of Actors is heavy, but as I was pointed on on IRC, is not something to be concerned with. Games are not real time application, and there many factors responsible for game responsiveness, and spawning new objects at run time is one of possible hundreds of factors, and not even most important one.
Get it working first, and then start worrying about how it works, otherwise you will never get something working ;).
Another fact. If you are planning to creating (by using new) 50k objects in single batch on single thread, you can be sure that thread will be locked for some time, regardless of how simple your objects are. In that case I would really reconsider your design first.
- Deffer creating object to what you really need at time.
- Try spawning object in separate thread, and then pass references to them to your main working thread. Just a thought, I’m not really expert on multi threaded programming, so I dunno if that is possible (;.
Simplifying data structure you are using to store/manipulate your data, is often most obvious solution, but it doesn’t means is the best one.
It will just simplify problem, but won’t fix it.