While trying to make a chest with loot inside + some visual UI (something like Minecraft), I’ve created a data table that holds static data (such as icon, name etc…).
And to specify what items the chest holds, I have an array of “Data Table Row Handle”, which makes it super easy to specify the items.
So my question is: is this bad on memory, or should I resort to using a “Text” variable as the item id/specifier. -Also how can I test this stuff?
My main concern is from what I understand the Data Table Row Handle holds a reference to my Data Table, so if I have an array of it with 100 items for example, I’m worried it will cause some issues. But maybe I’m overstressing it and Unreal takes care of it?
As a side note: I don’t want to use enums as then every time I add a new item I need to add a new enum entry (and I’m too lazy for that :P).
Yes when you spawn/placed a chest, it will load the whole data table.
In some situation level streaming will take care of that but you should see if it possible in your game to have multiple chest on the same area and x100 item per chest might be worrying. (you can calc the memory cost for example take the icon texture size and multi by 100, you will get an approx of the mem size and see if it worth to optimise). There also Reference Viewer that you can check out.
otherwise here some few solution:
use of soft ref for your icon texture
use of Data Asset instead of Data Table(i havent try this out but usually it won’t load everything until called)
proper level streaming
max out item per chest or reduce the resolution of your icon
(small tip) if you are using it in a widget, don’t forget to set your texture for UI group (it will remove mipmap and reduce it mem size by a bit)
when using soft ref, you will need to manually load the icon texture and add some condition if needed whether it loaded or not. Using the node CancelLatent is pretty useful in widget.
That is interesting, I was sure the data gets loaded only when I asked for it (for example when calling the “Get Data Table Row” function).
I am aware of soft references, I was just curious about the Row Handles as I’m trying it for the first time. I’m of course not gonna have 100 items per chest -I just threw a random number.