- Home /
Question by
danielbindy · Jun 08, 2020 at 09:18 AM ·
memory management
Addressable's assets are not being released when using AssetReference.InstantiateAsync
I have two addressables(AddrA and AddrB). At the beginning of the scene I load AddrA. AddrA has a button that unloads itself and lads AddrB. I load them using AssetReference.InstantiateAsync and when I unload them I use Addressables.ReleaseInstance. But when I check the profiler. When it goes from AddrA to AddrB none of the assets are being released and AddrB assets are being added. Then from AddrB I switch back to AddrA and again none of the assets are released. How can I make sure that the assets are released?
private async Task Load(AbstractNode node, bool showLoadingScreen = true)
{
AbstractModule module = (AbstractModule)node;
if (CurrentModuleController != null)
await UnloadCurrent(CurrentModuleController.Model.Type != module.Type);
GameObject moduleGameObject = await ModulesControllers[module.Type].InstantiateAsync(Vector3.zero, Quaternion.identity, transform).Task;
CurrentModuleController = moduleGameObject.GetComponent<IModuleController>();
await CurrentModuleController.LoadAsync(module);
}
private async Task UnloadCurrent(bool releaseAsset)
{
await CurrentModuleController.UnloadAsync();
//TODO Release asset too
Addressables.ReleaseInstance(CurrentModuleController.GameObject);
}
Comment