I'm again stuck with the termination problem of game, this time it's beacuse of memory overflow I though, As when I replay the level, by follo开发者_开发百科wing steps:
Step1: There is a menu button, on tapping which menu popup opens, this is achieved by a push scene
that pushes a menu class ove the previous scene
popping up the scene
,
2.replay level,
3.back to home,
The last two are achieved by replacing the scene, which leads to serious memory leak, because the dealloc of the previous class doesn't get called, So, in allocation it shows memory increase of about 10-20mb, and no reduction. Which probably leads to termination of the problem.
How to overcome this problem? I'm badly stuck with it.
It sounds like you aren't releasing something from your Scene. Dealloc is only called when the retain count of an object is zero. Have a look over your code and ensure that each of your objects is properly released when you're finished with it.
The Analyze tool (Cmd + Shift + B by default) in XCode 4 should give you a good idea what you're leaking.
Well what i did to over come this problem was an tricky solution:
Here are the steps:
step 1: made a global variable (flag)
step 2: store action in that global variable, as to replay or to back home
step 3: pop up the pushed scene(that have released the memory of push scene)
step 4: check what flag is saying in schedule selector(to re-play, or to back to home)
step 5: replace the asked scene(that release memory of current scene)
This is how I achieved it, any suggestion over it will be highly appreciated.
精彩评论