Textures are referenced after asset release

Hi,
If I load prefab from the addressables, and that prefabs material require texture this texture is loaded to the memory.
When I unload this prefab texture remain loaded with reference to non-existing object.
Easy to check in develop build with attached profiler.

No matter if textures/materials are in the addressables too.

I reported it but Unity reports are good for linux users for whom time have no value :slight_smile:
Is there any correct option for unloading referenced textures or it is just a bug?

You need to call Resources.UnloadUnusedAssets() for unloading not directly loaded assets (ex, texture or mesh which is referenced from prefab). Addressables only address directly loaded assets.

It doesn’t work because this texture have a fake reference. I’m releasing instance (if exists), loaded asset, assign null to asset and instance(if exists) and call unloadunusedassets().

The only think that works for me is to find this texture by hand and call destroy on it but than I can’t load it again.

Two general notes: Addressables uses the standard loading/unloading path fro assets in bundles. Second, you should generally try to avoid using UnloadUnusedAssets as it usually causes performance hits.

Now, specific to this…

I’m guessing you’re loading a prefab that does not actually connect down to a texture, then using addressables to load a texture and set it in that prefab? Assuming I understand correctly, then that texture will not be unloaded unless you release it. ALL load/instantiate calls need to be paired with a release. Addressables does ref-counting, and will hold on to anything that doesn’t get it’s count released back to 0.

Let me know if I’m misunderstanding.

-Bill

Hi Bill,
As simple as possible:
In empty project create a cube.
Create a material for that cube.
Add any texture to the project and add it to this material albedo.

Create a prefab from this cube and add it to any addressables group.
Load this prefab from addressables and unload it.
You can also instantiate it and release instance and also release asset as self - doesn’t matter texture will reamin in memory forever. I reported it (1083257).
I tried to put material and texture in addressables too but it changed nothing.
Check in memory profiler snapshot on build

1 Like

Thanks for the simplified description. We are looking into that ticket.

-Bill

Hello there. Any updates? Still happens in 1.6.2

Also interested in this case. What would be the best practice here?

1 Like

Any update on this issue? I’m on 1.6.0 and running into what seems to be the same problem.

2 Likes

Any update ?

1 Like

Any Update?

1 Like