Hi all ……
You know iPhone doesnot have garbage collection like ANDROID. So it becomes the responsibility of the developer or programmer to release the resources and remove the unwanted textures from your memory.
If you don’t remove the unused textures and other variables from your memory your application will exit after a while.

You often have the problem that your iPhone application exits unexpectedly, Most probably this may be the reason.

One method to check is…….
1. Release variables declared inside a function from there itself.
2. Release other variables inside the dealloc() function.
3. Remove the textures that remain in memory when you use images.
4. If you are using particle effects then don’t use the particle release function.
5. Unload the sounds on dealloc.

For removing the variables you can use..

[my_var release];

For removing the textures from the memory use this code inside the dellaoc function.
Check out the console if it is working. It will show console outputs such as “removing unused texture bla bla bla..”

/** this will remove all the unused frames if you are using sprite sheets **/
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
/** this will remove unused textures of images if you are using only images **/
[[CCTextureCache sharedTextureCache] removeUnusedTextures];
/** this will remove all textures from memory **/
[[CCTextureCache sharedTextureCache] removeAllTextures];

But still your program may exit. This is due to the second line and put only the this line..

[[CCTextureCache sharedTextureCache] removeUnusedTextures];

This may solve your problem…….
This above code will release most of your unused memory.

Please leave your valuable comments if this post was useful…..

 

One Comment

  1. Haster November 30, 2011 at 2:45 am

    Usefull??? You have saved my life!!! Thanks!!!!

     

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.