In my application I need to use a lot of short different mp3s (about 500 items one at a time)
So I use SKAction playSoundFileNamed
After ~ 200 sounds, it crashed with "Could not load resource - resource s234.mp3 cannot be loaded." Memory rises to 70 mb.
How to avoid this?
What I tried:
recreate sound at each iteration
SKAction *mySound=[SKAction playSoundFileNamed:aa waitForCompletion:YES];
create one variable at the beginning of .m
SKAction *mySound;
and reuse it in iterations
mySound=[SKAction playSoundFileNamed:aa waitForCompletion:YES];
2. load all sounds into the array once at startup
for (int j=0;j<500;j++){
NSString *aa=[NSString stringWithFormat:@"s%d.mp3", j];
[item.sounds addObject:[SKAction playSoundFileNamed:aa waitForCompletion:YES]];
}
... but never changed - it crashes and cannot download mp3.
How to clear a memory leak?
EDITED
I also tried disabling ARC and manually disabling it every time. Nothing changed.