Hi Andy,
Thanks for reaching out.
There might be a few things at play here, so let me know if I haven’t covered your case.
I’ll answer your questions below, but these steps might help you out regardless:
1- Generation happens in the editor.
If the generation happens in the editor only, you can mark the component (or the PCG graph) as editor-only, and the data will be removed at cook, which might be a good idea if you don’t need it.
2- Generation happens at runtime (once on load)
It’s possible that you serialize/have serialized data on the components that isn’t needed.
Any data that’s passed to the output of the “top” PCG Graph (e.g. the one in the PCG component) is serialized on the component itself - it’s used to be able to pass data between different components.
However, if you’re not using this or are not relying on that data, you don’t need to serialize it - ergo don’t return it.
3- Generation happens at runtime (once on load) and you need to pass data to other components
It’s possible to remove attributes from data (Remove / Keep attribute node) that will strip out that data and that might be worth it if that needs to be serialized.
4- Generation happens at runtime, but there’s nothing on the graph output
Data can be serialized for hierarchical generation, if so, please refer to (3) as it is similar in nature.
Otherwise, maybe you’re in a case that the cache is holding on to data that’s not needed anymore.
The pcg cache can empty and trigger a GC under some circumstances, and you can play with these numbers (pcg.Cache.MemoryBudgetMB is one) to adjust what makes sense.
You could also empty the cache completely (if you’re currently loading - through pcg.flushcache, or from the PCG subsystem “FlushCache” method) then trigger the GC for good measure.
Ok, so onto your questions:
1- Is it possible to remove [data] from the serialized runtime data if it’s not used?
You can’t remove the entry to value key map (it’s used!) per se, but as I pointed out, you can remove attributes you don’t need, and that will get rid of the memory.
2- What’s the difference between generate on load and generate on demand?
The generate on load happens when the PCGComponent has its OnBeginPlay method called, after streaming in.
The generate on demand is when you want to manage generation yourself - either as part of your tools in the editor or following whatever’s happening in your game (triggers, etc.)
There is no functional difference in how things are executed otherwise.
3- Is it possible to reduce the overhead of the data, based on how the PCG graph is setup?
It is very possible to do, and you might notice that we do it in some of our samples/plugins (such as BiomeCore) or Electric Dreams, where we’ll aggressively remove attributes we don’t need or abstract multiple attributes to an index in a table and so on.
The problem is especially prevalent when you do long chains of operations and add more and more attributes; reusing attributes and so on might be a reasonable idea in some cases.
On a side-note, in 5..6 we’re introducing a new data structure for points that can lower significantly the memory cost which might interest you - basically we’ve added a SoA version of the point data and that becomes the default point format we flow through the graph. It allows us to allocate only the properties needed, and also support inheritance.
Hopefully this helps,
Cheers,
Julien