Using TArrays doesn’t solve the problem as they will have a collection of pointers that are contiguous, but not the objects themselves. Heap fragmentation will occur. Just curious how the community handles this issue.
No.
Frankly we just don’t worry about it when it comes to UObjects. If something needs the benefits of contiguous memory, we use something else. Like Mass. But for UObjects you just have to leave it up to the Engine. Even the large professional projects that I’ve worked on, don’t bother.
@MagForceSeven Wow, okay thanks. In your experience, is it possible to have a data oriented design approach in Unreal C++? By data oriented I mean focus on data locality (temporal and spatial), memory layout (SOA vs AOS), reduction of heap fragmentation, etc. Use of CPU cache and memory management.
Is trying a data oriented approach fighting with the engine, as philosophically, the engine never was designed with that approach in mind? I would imagine trying to use a data oriented approach would require rewriting parts of the engine to get the full advantage of this approach. But I would like some more insight from you or the wider community experienced with the engine. Especially Unreal C++.
Yeah, the majority of the engine isn’t really intended to work that way. There’s nothing that stops you from writing something yourself that way though. The engine is still C++ after all, so all of that is still at your disposal. Depending on how much or little of the engine you try to interact with.
It’s possible some of the lower level systems, like rendering or particle systems, do use those tools at some point in their implementations but not in a way that’s ever been obvious to me or made available to manipulate.
My understanding is that Mass is the intended solution for doing things in a data oriented way, but I haven’t messed with it myself. It’s a more recent addition to the toolkit provided by Epic.
For the sort of development I’ve done in the gameplay space, it’s never been an issue and a data oriented approach would likely not have provided any performance gains over the solutions we built using UObjects.