Memory issues

Hi all,

I have started to experience some weird memory issues with the game (for iOS, cocos2d-2.0-x-2.0.4) that I’m developing. Here is what it happens:

  • If I run the game from Xcode into my iPod, then everything goes alright.

  • If I archive my game for ad-hoc distribution, and install it on my iPod through Testflight, then it crashes at the same point and I get the following crash report.

http://pastebin.com/kYbvbkFE

It crashes on my loading screen, while I’m creating the animations and adding to them the sprite frames that I’m going to use on the next scene. I’m not using texture packages, what I’m doing is to load individually each png image that makes up the animation and add them to a CCAnimation object invoking addSpriteFrameWithFileName().

void ShitLayer::loadCachedAnimations()
{
    cocos2d::CCAnimation* currentAnimation = cocos2d::CCAnimation::create();

    currentAnimation->addSpriteFrameWithFileName( FilePath::SHIT_LAYER_STATE_0 );
    currentAnimation->addSpriteFrameWithFileName( FilePath::SHIT_LAYER_STATE_1 );
    currentAnimation->addSpriteFrameWithFileName( FilePath::SHIT_LAYER_STATE_2 );
    currentAnimation->addSpriteFrameWithFileName( FilePath::SHIT_LAYER_STATE_3 );
    currentAnimation->addSpriteFrameWithFileName( FilePath::SHIT_LAYER_STATE_4 );

    cocos2d::CCAnimationCache::sharedAnimationCache()->addAnimation(
    currentAnimation, SHIT_LAYER_ANIM_NAME );
}

So, for me it looks like an out of memory issue, but it is strange that it works just fine if I install my app from Xcode, instead of using the .ipa created for ad-hoc distribution. The only difference that I see is that the first one is signed with my iPhone Developer Profile, and the second one with my iPhone Distribution Profile. Is there any difference concerning the available memory for these scenarios? Am I missing anything else?

Thanks for your help!

With crash log, it doesn’t seem like to be memory issue to me. It looks more like that you are trying to create a spriteframe with a file which doesn’t exist in the resources. Can you check once again if all the desired resources copied to your app while building distribution profile?
Or why not try to first add all sprite frames in CCSpriteFrameCache and used it while making the Animation?

Paras Mendiratta wrote:

With crash log, it doesn’t seem like to be memory issue to me. It looks more like that you are trying to create a spriteframe with a file which doesn’t exist in the resources. Can you check once again if all the desired resources copied to your app while building distribution profile?
Or why not try to first add all sprite frames in CCSpriteFrameCache and used it while making the Animation?

Great! You are right. I was using the wrong file path for my images. I had moved them recently into a different directory, and I suppose that when I ran my game from Xcode, the previous directory was copied too into the device… That’s why it worked in that case. Thank you very much. I had blinded myself with the memory thing for some days and all I needed was to better understand the crash report :smiley: