Low memory crash

Hi guys,

I’m getting a strange low memory crash in my build on the iPhone, but I’m not sure why. It happened after I added a couple more sounds (I’m up to around 20, preloaded on a game object in the intro scene that is kept in place by DontDestroyOnLoad). I’m not sure what set it over the edge, but it seemed, after I compessed them to mp3, the crash happened later (still between loading scenes).

Any suggestions on tracking this bugger down? I’m at a complete loss, and I don’t want to remove sounds if I don’t have to (besides, I think it’s a memory leak of some type.)

Thanks for your help!
Duane

run it through instruments so you can see what’s going on. also have you rebooted your iPhone lately? it won’t clean up released memory until you do which can cause memory probs.

20 sounds preloaded on a game object are a good reason for crashing as thats a massive amount of memory already with AAC files, not counting in the consequence of wav

yeah probably. tho it depends on settings, how long they are etc. so that might not be the only prob but yeah it sounds like a lot.

Thanks for the replies guys. I really appreciate it!
Dreamora, is there a better way to load (and/or unload) sound effects? Should I just call them all individually? In this instance, a tick of performance hitch isn’t nearly as bad as a full blown crash :slight_smile:

optimally you would load them when you require them, play them and then destroy them again so they don’t float around in memory uselessly.

And I would consider reducing the amount of sounds … 20 that need to be cached at the same time sounds like a lot for a device that would be fully eaten up if only half those sounds were played in parallel, without the 3d work.

Load and destroy them as required… do I do this by creating individual prefabs, or is there a way to destroy a sound directly?

Ok, I’ve gone through and put all the sounds on prefabs and instantiate/destroy them throughout my various scripts, but I’m still getting the error… Is there anything I can do to track this down? If it’s not coming from the audio, I’m lost as to how to find it!

use the memory tool in xcode to analyze your app.

you don’t track this kind of stuff in and from unity at all

Hi there

I just found this comment in another topic which I believe is similar to the problems that you’re experiencing: http://forum.unity3d.com/viewtopic.php?p=204387#204387

Brady found that when he was switching between scenes there was a bug relating to the use of compressed MP3 audio. He said after using an uncompressed version of the same sound, it worked fine and stopped crashing.

I Hope this helps is still relevant.