How to Simply Manage Texture Release?

Texture will take up a lot of memory, so I want to manage it in a simple and effective way.

I found that texture has such a function in playcanvas
image
But this destroy method I checked that the following material destroy was not invoked, that is to say, this method needs to be called manually, but I released if there are references that will lead to errors, I want to know if there is a simple and good way to deal with it.
I think the engine should add a reference count to the texture?

Looks like asset.unload should release the VRAM used by the texture and you can use asset.loaded to check if the resource has been loaded.

Links:


https://developer.playcanvas.com/en/api/pc.Asset.html#loaded
https://developer.playcanvas.com/en/api/pc.Asset.html#unload

If the texture asset is used in the material of another model, calling unload will cause an error.
I think this problem is more troublesome, maybe we have to count the resource references, and unload can be invoked only if it is not used.