Author Topic: Best practice for clearing Substances from memory? Clearing the Cache  (Read 428 times)

I have just ported my old 2017 project to use the plugin version (2.5.4) in 2020.3 LTS.
Everything works as expected on PC, however I recently tried it out on iOS and discovered that every time I instantiate a substance and set its unique parameters it is cached. This is fine in the sense that I do occasionally need to re-use/modify the substance during the session. However what is not fine is that every time I load a new scene with a new set of parameters the old substances remain cached. Even when I reload the same scene a second time it creates completely new instances rather than using the ones from initial creation. Of course this eventually leads the system to run out of memory and crashes the App.
In lieu of there being any comprehensive instructions or documentation for the Unity Substance API, could someone let me know the best way to clear the substance cache every time I load a new scene? I did read in another thread that you can use asset bundles but this would appear to be a very ad-hoc approach. Surely there is a better way?
I hope you can help,
Thanks, Andy

Worth noting I believe this behaviour is the same on all platforms, it's just that I noticed it first on iOS where there is a greater limit on resources. Thanks, A

I have tried destroying the textures and the substance and they disappear visually as anticipated and yet they seem to still be in memory? Any help would be greatly appreciated. Are Asset Bundles the only way to handle this situation?