Explicitly freeing texture memory

Memory being scarce on the iPhone and all, I’m wondering if there’s a way to explicitly free up texture memory within a single scene. I have objects I display for a time, then remove from view for a good while and load other objects in their place. It would be great if I could free up the texture memory being used by those objects to make way for the new ones.

Is there a way to do this?

Thanks!

file:///Applications/Unity%20iPhone/Documentation/ScriptReference/Application.GarbageCollectUnusedAssets.html

Although the documentation is a bit sparse on what exactly this function does, I have run into errors where I could reliably crash the iPhone at a certain place in my code unless I called this function before reaching it - so I am pretty sure it can do what you want.

Yeah, somebody mentioned that function to me once before, but its behavior is completely undocumented so I have no idea if it will really do what I need or not. I tried using it at one point and every time it was called, it caused my game to stop for a good part of a whole second. But my VBO count kept increasing even though I was destroying the objects. So I’m not sure if it really does what I’m needing.

Guess we’ll have to wait for a reply from someone who knows Unity inside and out :slight_smile:

i also get this problem. Pls give me the answer…

This is an old thread - there is actually a function called Resources.UnloadUnusedAssets that solves this problem now.