.showsPhysics的内存泄漏

luc*_*an5 8 memory-leaks ios sprite-kit swift

我刚刚花了最近5个小时试图在我的Spritekit App中调试内存泄漏.

应用程序启动后,我注意到我的内存使用率略有上升.

我花了5个小时中的3个时间挖掘参考资料,用ARC学习强VS弱(绝对推荐阅读像我这样的中间体)

还有其他人遇到过这个问题吗?如果有的话有什么解释吗?这是我的GameViewController的一小部分:

class GameViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    if let scene = MainMenu(fileNamed:"MainMenu") {
        // Configure the view.
        let skView = self.view as! SKView
        skView.showsFPS = true
        skView.showsNodeCount = true
        skView.multipleTouchEnabled = true
        skView.showsPhysics = true

        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true

        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .Fill

        //var GameSaveData = GameData()

        // Scene Config
        //scene.Landscape = "Test_Landscape"
        //scene.Area = "Start"

        skView.presentScene(scene)
    }else{

        print("Couldn't Load Game Scene")
    }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我在这里并没有做任何与众不同的事情.我会发布我的gamecene代码,但在我仍在观察内存泄漏的时候,它都被注释掉了.

luc*_*an5 8

最终,出于贪图,我刚开始评论代码行,然后构建和分析,直到内存泄漏得到解决.

原来我的GameViewController.swift文件,

skView.showsPhysics = true
Run Code Online (Sandbox Code Playgroud)

是罪魁祸首.这肯定是一个新的错误,因为我在<IOS 9.2中没有看到这个问题