In my application I need to use a lot of short different mp3s (about 500 items one by one)
So I use SKAction playSoundFileNamed
After ~200 sounds it crashed with 'Failed to load resource - Resource s234.mp3 can not be loaded'. Memory rises to 70mb.
How to avoid this?
What I tried:
recreate sound in every iteration
SKAction *mySound=[SKAction playSoundFileNamed:aa waitForCompletion:YES];
create the one variable in the beggining of .m
SKAction *mySound;
and reuse it in iterations
mySound=[SKAction playSoundFileNamed:aa waitForCompletion:YES];
2. load all sounds to array once at start
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 can't load mp3.
How to clean this memory leaks?
EDITED I also tried to turn off ARC and manually dealloc it every time. Nothing changed.