Is there a way to purge the asset cache at runtime?
I want to be able to re-run timings without having to restart the editor. The first load of my model (thousands of meshes in a scene component) takes say 10 seconds, subsequent loads take 3 seconds. I want to be able to clear the cache between loads - so that each load takes 10 seconds.
The process I’ve tried is to use the Asset Registry to get Asset Data, convert Asset Data to a Primary Asset Id and then use Asset Manager’s Unload Primary Asset. And then call Collect Garbage…
The documentation for “Collect Garbage” says it’s performed at the end of the frame - so I’ve coded a delay into the event tick to give it time to complete. Collect Garbage should be synchronous - but I’ve put in a nice long delay (I’ve tried up to 10 seconds), in case it’s not. But that’s not helped:
Each new load is using cached data (taking 3 seconds instead of the 10 seconds I see when I run things the first time).
If I can’t do this with BP is there a kind soul out there who could point me in the direction of some C++ to do this?
Many thanks!
p.s. I realized my code had a bug and was only trying to remove the meshes, and not the materials as well. But, even after fixing that, it’s still behaving as if all the data is still in the cache…