tvOS 10 memory allocation bugs?

89 views Asked by At

I am writing a tvOS app that is having apparent leaks/memory allocation problems. Since the update of Swift 3 and tvOS 10, I have noticed substantial memory issues. The app is supposed to run constantly for days/weeks, and with Swift 2 and tvOS 9, it ran fine. Now, my app runs for 2-3 days and crashes. I have been banging my head at my desk for over a week now.

I have used Instruments to diagnose and solve most (if not all) of my leaks, but I still have a slow rise in memory usage in my app. Despite Instruments showing no leaks, the memory usage tracker in XCode still shows a slow and steady rise in memory. I have been tracking Allocations using Instruments, and have found some peculiar things:

1) When I add a SKCropNode to a SKSpriteNode, my Persistent bytes and # rise quickly.

var cropNode: SKCropNode!

func prepare() {

    let node = SKSpriteNode()
    node.anchorPoint = self.anchorPoint
    node.size = self.frame.size
    node.color = UIColor.black

    self.cropNode = SKCropNode()
    self.cropNode.maskNode = node
    self.addChild(self.cropNode)
}

2) I have added many many measures to clean up everything when I dismiss a scene, but again, the persistent bytes and # continues to rise. I am using weak references wherever they are appropriate.

func exit() {

    let fadeAction = SKAction.fadeAlpha(to: 0.0, duration: 0.35)
    self.run(fadeAction, completion: { [weak self] in

        self?.removeAllActions()
        self?.removeAllChildren()
        self?.view?.presentScene(nil)
        self?.removeFromParent()
        self?.view?.removeFromSuperView()
    })
}

My questions are:

Has anyone come across memory issues within Xcode 8, Swift 3, or tvOS when updating from older versions?

Does anyone have any explanations or solutions for the issues I listed above?

Thanks in advance :)

0

There are 0 answers