问题描述
我很好奇当 showsFields
打开时,内存使用量增长得非常快?它可以在30秒内增长到500MB。如果我的mac只有8GB的RAM,我可能在内存警告之前调试不到8分钟,在真实设备上进行调试时效果最差。
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.
下面的截图从真实设备(iOS 9.2)进行测试。
The screenshot below is tested from a real device (iOS 9.2).
您可以通过创建SpriteKit项目快速尝试它,并在视图控制器内的 viewDidLoad()
方法中打开 showsFields
。
You can quickly try it by creating a SpriteKit project and turn showsFields
on in viewDidLoad()
method inside the view controller.
skView.showsFields = true
如果你想要查看 showsFields
的内容,请将此代码段放在场景的 -didMoveToView(view :)
方法中。
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)
}
这是 showsFields
来自Apple的讨论
Here is showsFields
discussion from Apple
当这个调试选项是启用后,每次渲染一帧时,都会在场景后面绘制一个图像,显示场景中包含的任何物理场的效果。
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.
推荐答案
看起来每帧绘制的调试图像没有被正确清除,这可能会导致内存泄漏。
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.
希望有所帮助。
亲切的问候,
Mukund
Kind regards,Mukund
这篇关于SpriteKit SKView显示字段内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!