Strange active memory allocation increase at startup - iPhone Unity3.4

Hi,

I have came across a strange problem and I can’t seem to fix it anyhow. I have searched the forum but haven’t found anything.

I have a game that uses a lot of vector3 arrays (about 30 with 10 elements each) but my drawcalls are under 20, verts 1.2k.

I built the game (only consists of 1 scene) and installed on my iPhone 4 and also on my iPod Touch 2G.

The problem is that if I run it on the iPhone 4 with Instruments, the active memory allocation increases to 21mb at startup and then returns to about 7mb and stays there throughout gameplay. However, when I run it on iPod Touch 2G, the active allocation keeps increasing on start-up until it reaches 52mb and then the game gets terminated by iOS.

I do not see how this is possible and I need to fix this issue asap. Do you have any suggestions?

Thanks

bug report with repro project

it doesn’t happen in my other games but only this one

I don’t know what exactly do you have in the scene. But if you draw debug text or other text with UnityGUI, you might have some allocation going on all the time.
But in any case the allocated heap should go through GC and shouldn’t cause crash.

I do not use any debug text. I deleted a few of the arrays and tried building again. This time, this is even weirder. When I run the game on the iPod not (disconnected from macbook), it works like a charm but when I test it with instruments, the active allocated memory still increases until it terminates the game.

lukas its similar to my GROWING thread of my build, from 100megs to 500… did someone put Yeast in the new 3.4?

I honestly don’t know, but even in the editor stats window, in 3.3 my fps used to be about 600fps, about 3ms per frame (high but that’s what it said in 3.3) and now it’s only 63fps with 13.6ms per frame. This could be linked with the allocations perhaps.

no, most likely it is linked with vsync

Thanks Alexey, the vsync option in quality settings inproved the performance in editor significantly (1.3ms/frame). But I still get that memory increase and turn off.

If it would help, I do use a lot of GUITextures; whole of my menu and gameplay background is made up of GUITextures. Many are full screen.

In xcode, I get this error: GDB: Data formatters temporarily unavailable.

Thanks again, your help is much appreciated. Now I just need to get it working on the device :slight_smile:

you are wrong - it didn’t improve anything. If you looked at profiler it will showed you that all the time was spent inside Device.Present. Performance is the same

that means that you crashed (or hit breakpoint) but xcode cant show you debug info
check Unity - Manual: Troubleshooting ios section

Anyway as i said - bug report with repro project

I figured out after a looking through the log in Instruments that 48MB is being actively allocated by GUITextures in Malloc1MB. This is my problem! I tested with the same scene without the GUITextures (that make up all my menus and are essential to the game) and the allocations stayed to 3MB.

I really need to have pixel perfect fullscreen 2D menus but how can I reduce the memory usage while keeping the quality?

BTW, those 48MB are just the low res guitextures. What will happen once I create a HD scene with retina textures?

Well, on some iDevices gles memory allocations goes there too - try to recheck if that’s the case. If it is - you’re out of luck :wink:

I just did a test. I made a scene containing only GUITextures (9 to be exact) and tested with instruments. In malloc 1MB there are 9 things and it says malloc1MB is taking up ~9MB of memory.

Here’s a screenshot:

Set textures to Advanced and remove mip mapping. This will save a fair bit of memory overall. If you’re setting them to GUI it performs this step for you so you won’t save any extra memory. Try 16 bit textures in that case, or compressed.

For what it’s worth I use 4x2048x2048 textures at full size on my ios game front end (its an app so it’s all front ends) and I don’t care. I just do not care. For android it’d probably die though.

responsible library is OpenGLES - meaning it is memory allocated by driver
so yes, follow advice of hippocoder or just search through forum/internets - it have nothing to do with unity per-se - so you should really fix it yourself

Ok thank you, I really appreciate your help.

The 16bit setting actually saved my day. Thanks :slight_smile: