I initialize about 30 animated textures in my view controller when loading the game as follows:
for i=0; i<atlasName.count; i++ {
frameNumber = animationTextures.animationTextureAtlas[i].textureNames.count
firstFrameName = "\(atlasName[i])1"
animationTextures.animationFrames.append([animationTextures.animationTextureAtlas[i].textureNamed(firstFrameName)])
for j=2; j<=frameNumber; j++ {
var frameName = "\(atlasName[i])\(j)"
animationTextures.animationFrames[i].append(animationTextures.animationTextureAtlas[i].textureNamed(frameName))
}
animationTextures.firstFrame.append(animationTextures.animationFrames[i][0])
}
Basically I put all the animations in an array so that I can easily access them.
During the game, each of these animations appears for a short period of time, and when I do not need them, I use .removeFromParent () to delete it, but the problem is that it still remains in the deviceโs memory and therefore once in the game about 15-20 animations appear and enter the memory, it reaches about 450-500 MB and crashes out of the game on iPhone 4 and 4s.
Does anyone know how I can really remove this animation from memory so that it does not take up space if it is no longer needed?