Device Test Problem - Memory - CCSpriteFrameCache

Hello guys ,

Today i started to test in IOS device 3GS and im having a problem with the CCSpriteFrameCache loading my plists.

  1. Same project , with same resources run in Droid2 without lag or memory problem (load all resouces) (droid2 is much worst than Iphone3GS)
  2. I cleaned all apps of 3gs Memory , so its clean
  3. First my texturePacks were configured with RGB8888 , the best , i changed to RGB4444 , so i take 1/2 of the last size of all resources.
    now its about 14Mb of resouces in 12 pngs archivies of 1024x2048
  4. I tried to load just se necessary at firs , and after in the loading of the game i load some other stuffs , but looks like the memory that i can allocate is very small.

I received the message [12184:907] Received memory warning.
(this is my applicationDidReceiveMemoryWarning

  • (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    cocos2d::CCDirector::sharedDirector()->purgeCachedData();
    )

Even with all this changes the app crashes after loading 5 or 6 plists.

This is how i load my resources:
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“images/texturePack3.plist”);

Any Ideia for this problem? thanks
i already lost my day!

Is resource size 1024*2048?
I am not sure if Iphone3GS supports this size.
Please confirm it first.

About the memory warning, i think you can do these steps

  1. checkout how much memory can be used
  2. checkout if there is memory leak

What’s the version of cocos2d-x did you use?

Hello Minggo

The resource at start was 2048x2048 , in simulator runs ok , but with the device crash
then i passed all textures to 1024x1024.

I checked and it was no memory leak , just 93 mb of memory allocation when it crash.

i have 14 plists , and the game crashs when are loading the 6 or 7 plists.

How can a check how much memory can be used?

cocos2d-x - version = cocos2d-1.0.1-x-0.12.0

thanks!

Minggo Zhang wrote:

Is resource size 1024*2048?
I am not sure if Iphone3GS supports this size.
Please confirm it first.
>
About the memory warning, i think you can do these steps

  1. checkout how much memory can be used
  2. checkout if there is memory leak
    >
    What’s the version of cocos2d-x did you use?

Hello Guys

Im really worry about memory allocation in devices , this is my first app and im passing by all the problems.

  1. The primary error was that in my loading scene was loading all the resources of the game! thats crash in the first device test ( I have about 14 png texturepack)
    1-1) To resolve i just distributed the resources by demand , so when in a scene i need some images in the onEnter() of CCLayer or CCScene i load the CCSpriteFrameCache::sharedSpriteFrameCache()~~>addSpriteFramesWithFile
  2. In the desallocation i clean the SharedSpriteFrameCache
    Ok , with this steps i resolved the iphone3gs and 4/4S
    Now the problem is IPAD1~~ when i load the first spriteSheet it received a memory warning and just crash! what is more straight , i just load one simple sprite and this crash!

Cocos2dx guys and friends , any idea? i Ipad1 has low memory than iphone3gs?

version = cocos2d-1.0.1-x-0.12.0

Thanks

Hello , i have resolved some problems but continues to crash when you uses the app by some time.

Using the Instruments , i noted that what most increase the memory is the use of Audio APi , in attach you can see that SimpleAudioEngine playEffect increase 4 MB , there is a way to release this memory?

Thanks

Moc Interactive wrote:

Hello Guys
>
Im really worry about memory allocation in devices , this is my first app and im passing by all the problems.
>

  1. The primary error was that in my loading scene was loading all the resources of the game! thats crash in the first device test ( I have about 14 png texturepack)
    1-1) To resolve i just distributed the resources by demand , so when in a scene i need some images in the onEnter() of CCLayer or CCScene i load the CCSpriteFrameCache::sharedSpriteFrameCache()~~>addSpriteFramesWithFile
  2. In the desallocation i clean the SharedSpriteFrameCache
    >
    Ok , with this steps i resolved the iphone3gs and 4/4S
    >
    Now the problem is IPAD1~~ when i load the first spriteSheet it received a memory warning and just crash! what is more straight , i just load one simple sprite and this crash!
    >
    Cocos2dx guys and friends , any idea? i Ipad1 has low memory than iphone3gs?
    >
    version = cocos2d-1.0.1-x-0.12.0
    >
    Thanks

Hey moc, you can check your memory usage with dumpCachedTextureInfo()
You also can check your available memory on your device. This site provide a way to check it, http://iphone.syuhari.jp/2012/04/20/how-to-display-a-E280�available-memory-counter”-for-cocos2dx/

I’m getting this crash too when cache 5 spritesheet (2048x2048) on iPad 1.
In simulator and iPad 3 its working perfectly.
Is there any solution? Should I not cache the image and use spriteWithFile instead?
Thanks

Yes , im using this code too , i see that my memory dont decrease with the gameplay , the instruments is good to see some wrong allocation in your code , but i cant use it to find the main problem.

I have the same problem , i have about 14 shprisheets , and my solution was , reajust the spritesheet for commons things like menu , gameplay , about , tutorial and now i have 25 spritesheets but with small size , and when you load just the necessary the IPAD 1 dont crashs. Testing i concluded that IPAD1 is worst then Iphone3gs. IN Iphone3gs i can load more spritesheets in a row than in IPAD1.

This kind of problem is very complicated , depends how is your code you will have to make some refactory! : (

Diori Cergy Castali wrote:

Hey moc, you can check your memory usage with dumpCachedTextureInfo()
You also can check your available memory on your device. This site provide a way to check it, http://iphone.syuhari.jp/2012/04/20/how-to-display-a-E280�available-memory-counter”-for-cocos2dx/
>
I’m getting this crash too when cache 5 spritesheet (2048x2048) on iPad 1.
In simulator and iPad 3 its working perfectly.
Is there any solution? Should I not cache the image and use spriteWithFile instead?
Thanks

Yes, my testing also show that iPad 1 is worst than iPhone 3GS, which is can load more spritesheets in a row.
And, the crash lesser occur when the device unplugged from XCode.

I solved this problem, but I don’t know which changes fixed the crash.
I tried replace the cache placement and order. Repack the spritesheets.
Some animation not working too, then I re code it, rename the instances and its working again (such a strange bug).
Replace some jpg with png, iPhone 3GS shows black image with jpg files.

I wish you can solve this nasty thing soon, good luck :smiley: