12
votes

I am curious about when showsFields is turned on, the memory usage increase extremely fast? It can growth up to 500MB under 30 seconds. If my mac only have 8GB of RAM, I probably have less than 8 minutes to debug before memory warning, it will be worst when debug on real device.

The screenshot below is tested from a real device (iOS 9.2).

Memory Usage

You can quickly try it by creating a SpriteKit project and turn showsFields on in viewDidLoad() method inside the view controller.

skView.showsFields = true

If you want to see what showsFields does, place this snippet inside the scene's -didMoveToView(view:) method.

override func didMoveToView(view: SKView) {
    let myField = SKFieldNode.springField()
    myField.position = CGPointMake(frame.midX, frame.midY)
    myField.strength = 1.0
    self.addChild(myField)
}

Here is showsFields discussion from Apple

Discussion

When this debugging option is enabled, each time a frame is rendered, an image is drawn behind your scene that shows the effects of any physics fields contained in the scene.

1
Have you tried on a real device? SpriteKit on the simulator is quite buggy and inefficient.jcaron
yup, memory warning force the app to quitKent Liau
It's a bug. Expect it to be fixed in 2017. or 2018. But not tomorrow.Confused
I just ran into this too. Eating memory FAST. Crashes app within a few seconds. iPhone 6 Plus, iOS 9.2.1, going up to hundreds of MBs in an instant. And I don't actually see any debug output!Jonny
the debug output is visual output, try add a physics field into your scene, it should be visible, still it can only last for short period of time before it finish up your memory.Kent Liau

1 Answers

1
votes

It looks like the debug image drawn per frame is not being cleared up properly which, is probably leading to this memory leak.

Best will to file a bug report with Apple via https://developer.apple.com/bug-reporting/ so they know multiple people are having this issue and can hopefully give a higher priority.

Hope that helps.

Kind regards, Mukund