I had the same problem, there was a lot of memory with my SceneKit application. The memory is SCNNode
freed if you set the geometry
value of your property nil
before allowing Swift to de-initialize it.
Here is an example of how you can implement it:
class ViewController: UIViewController {
@IBOutlet weak var sceneView: SCNView!
var scene: SCNScene!
override func viewDidLoad() {
super.viewDidLoad()
scene = SCNScene()
sceneView.scene = scene
}
deinit {
scene.rootNode.cleanup()
}
}
extension SCNNode {
func cleanup() {
for child in childNodes {
child.cleanup()
}
geometry = nil
}
}
source
share