Texture usage and out of memory issue

Hi All,

Thank you for taking the time to read this post :slight_smile:

I’ve searched the forum and seem similar questions asked before, but I couldn’t quite find the answer to my issues. So I would like to ask for your input if you don’t mind:

I am using Unity 3.1 on OSX to create a game for iOS. I have around 2000 images in jpg or png format, the game will load around 10-20 images into the game depend on user’s action, and as the game progresses, unload existing images and load new images. It’s very similar to an image album.

The problem is - the game keep getting unloaded by iOS because it use too much memory.

I attempt to clean up unused Texture2D by using Texture2D.DestroyImmediate, and Resources.UnloadUnusedAssets whenever possible. I also make sure all references to the Texture2D are cleared.

I also try to reduce the runtime memory usage for the texture2d by using texture compression (PVRTC). I tried the following approaches:

  1. Use www or filestream to load into an Texture2D created without mipmap, then called the Texture2D.Compress function

  2. Import the images into the Resources with Unity editor, set the compression to PVRTC RGB 4 bits. And use Resources.Load when I need the texture

  3. similar to (1) above, but instead of png/jpg, I created .pvr with texturetool.

The problem are:

for (1) the Texture2D.Compress doesn’t seem to do anything at all on the iOS. I also tried to create Texture2D with TextureFormat.PVRTC_RGB4, but got an error “can’t create with compressed format” error.

for (2) this does use a lot less memory, but I can’t seem to unload the Texture2D at all.

for (3) I couldn’t find anyway to load the .pvr into Texture2D

So I am stuck at the moment. At the moment I have to stick with (1), but I could only work with 8 images at one time before the game run out of memory. I have a feeling I am missing some important clue. I would appreciate any advise here.

Thanks in advance!

Have you tried using Resources.UnloadUnusedAssets in conjunction with approach 2?