SpriteKit - Do you need to do memory management? (Removing nodes after the scene is no longer required, etc.)

I created the game through SpriteKit, and for this I use SKScenewith SKSpriteNodesand SkNodes. When the user dies, I have a parent view controller SKScenethat runs a segueto play through the View Controller. I delete the part SKSpriteNodes, but none SkNodesof the game scene. When the user presses the play button again, he goes to the view controller with SKScene, and the game starts. I was wondering if I need to remove SKSceneits nodes from memory after the user dies and before I get segueto the game through the View Controller. Is all SkNodesandSKSpriteNodesthat I created are still stored in memory? I ask this question because of how I noticed that after each game / memory mapping for my application displayed in Xcode and Instruments application, it is higher than before the match / game.

* If this is related to the problem, I have an Admob banner and an award-winning video ad loaded and displayed to the user in the game through the View Controller.

+4
source share
1 answer

They will be kept in memory as long as there is a strong reference to them.

Without code, we won’t know for sure, but the quick way you can check is to add this to your game and then execute segues:

deinit {
  print("gamescene go byebye!")
}

, . SKScenes, , .

, Swift, , :

https://www.raywenderlich.com/134411/arc-memory-management-swift

+3

Source: https://habr.com/ru/post/1680275/


All Articles