swift - Ios popToRootViewControllerAnimated causing Memory Issues -


i making spritekit game. when player dies, goal have game transition start screen. accomplished code below. however, notice memory increases each time new game begins. xcode instruments not showing memory leak. when memory reaches 150mb games frame rate drops , game become unplayable.

in gamescene call function when player dies

func gameover(){     if let block = gameoverblock {         worldnode.removeallchildren()         worldnode.removeallactions()         worldnode.removefromparent()         self.removeallchildren()         block()     } } 

back in gameviewcontroller following functions called

     scene!.gameoverblock = {         [weak self] in         self!.goback()     } }  func goback(){     scene!.removefromparent()     navigationcontroller!.poptorootviewcontrolleranimated(false)     return } 

if has ideas how can accomplish without memory leak, appreciated.

after commenting out tons of code, have found problem. methods have posted above not causing leak, matthew suggested, there strong reference in middle of code stopping arc releasing memory. ill post problem code incase else may have similar problem.

in gameviewcontroller, had following block:

  scene!.zoominblock = {        self.scene!.size = cgsizemake(self.scene!.size.width / 2, self.scene!.size.height / 2)     } 

the correct way (without causing strong reference) write be:

  scene!.zoominblock = {      [unowned self] in self.scene!.size = cgsizemake(self.scene!.size.width / 2, self.scene!.size.height / 2)     } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -