SpriteKit SKView showsFields memory usage

泄露秘密 提交于 2019-12-21 07:25:30

问题


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).

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:


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



来源:https://stackoverflow.com/questions/34903539/spritekit-skview-showsfields-memory-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!