I’m really hoping this is something simple…
I’m working on an arcade game with lots of shooting and a ton of enemies. Just recently I added a number of sound effects for creatures dying and weapons being fired, and noticed that afterwards my iPhone builds suffered from a slow and steady performance drop after playing for several minutes - starting off in a healthy 25-30fps range, and slowly dwindling down to approximately half that, with noticeable dips when sounds are playing. Disabling my sound effects fixes the problem - the framerate stays consistent over very long tests, but adding the sound back in instantly causes the problem again without fail.
My file sizes for my sound effects are uncompressed to allow multiple sounds playing simultaneously, but are all very short and low fidelity to keep file sizes down. They range from 15k up to 85k, the larger ones playing less frequently.
The way I’m playing the sound is pretty straightforward - I have an AudioClip variable for each sound whos reference is assigned via the inspector, and I use the following code…
audio.PlayOneShot(variableName);
… to play them through my main audio source, which also has my audio listener attached.
By the time my framerate has deteriorated significantly, I’ve probably played some of these tiny 15k sound files a couple hundred times. This seems like it shouldn’t be that big of a deal though, arcade games kinda need to play a lot of sounds over and over… is the way I’m playing these sounds potentially causing some kind of memory leak?