Memory Explosion

My game was consistently being “jettisoned” for taking up too much memory. This seemed to spring from a memory leak (at least it looks that way from the Instruments profiling)- so I created a scene with just the front end (GUI for choosing some game elements/character etc.)- to see if I could isolate the problem.

My front end is just a selection of textures (mainly 512x512s for compression) and 20 or so small ones at 300x50 (no compression obviously,) but it still dies a few seconds after load.

My asset folder is still full of all the game assets, but surely a build with only the active scene (the stripped down front-end) doesn’t contain any assets other than those referenced in the scene itself?

if so, are there any other things that are likely to cause a memory usage explosion?

Thanks in advance for any ideas.

I believe I read in another thread that any texture that does not have dimensions in powers of 2 (i.e. 128, 256, 512, etc.) will explode to ridiculous size. My guess is your 20 or so 300x50 textures are the culprits - extra assets in your project folder will not be included in your build unless the level(s) actually reference them in some way.

Thanks for the tip PNA.
I’ll give that a try and see if it has an impact.
(I’m guessing it’s a significant bug if it does.)

Also the iPhone cannot currently use non-square textures. So all the 300x50 textures are ending up as 512x512 uncompressed, which is simply far too much (somewhere around 25MB I think). It’s not a bug, but a device limitation.

–Eric

I have a query Eric,

512x512 texture when uncompressed it will take 4MB. How much it will take when it’s PVRT compressed?

512x512 is actually 1.3 MB (1MB + mipmaps)

pvrtc is 1/4 or 1/8 of it, depending if you use bpp2 or bpp4

Eric -

If we use power of 2 textures that aren’t square, will that also chew up memory? For example, using 512x1024 or 256x512?

Non square textures(such as 256x512 or 64x512) will not be scaled up to 512x512, so you’re free to use them, but they can’t be compressed using PVRTC. Only textures with one or both sides having non-power-of-2 pixel sizes (such as 300x50 or something like that) will automatically bloat to 1mb+.

I think it’s possible to use non-square pot textures as of the 2.2 firmware update… it was left out of 1.0.1 because making 2.2 a requirement was seen as a problem.

The PowerVR hardware will only do square power of two textures when using PVRTC, in any case.

–Eric

I’m not sure who to believe on this one… this is from ReJ a few months back:

I would believe an iPhone developer guy instead of me any day. :slight_smile: I’m just going by what I read on teh intarnets a while ago about this subject…having to always use square textures is a pain, so I hope it’s just a driver issue.

–Eric

Right- I think it shakes down like this:

non-power-of-two textures: unsupported nightmare.
non-square power-of-two textures: supported but no PVRTC compression.
square power-of-two textures: happy and compressed.

It’s particularly wasteful for GUI elements that are wide but not tall- but my tests would seem to indicate that as long as the textures are power-of-two in both dimensions- all you lose is the compression- which isn’t a big deal for what are generally pretty small files.

Thanks a lot guys for chiming in. This was not something that I thought would bring my entire game to its knees, but now I know the limitations, I can plan accordingly.

I tried copying the texture tool into the UnityIphone package and it still doesn’t seem to want to compress non-square textures (even though it is 1024x512). Any ideas?

Um, I probably should’ve left the last sentence out of that quote :wink:

That was from the iPhone beta list and I honestly have no idea what will or will not work past that point since the topic fizzled out. Best to assume that non-square pot textures are still a no go. Maybe ReJ will jump in and clarify this.