Control size of scene ARKit

Hi everyone!

My app can put on scene lots of usdz models but when scene has lots of models it may be crashed. How can I control size of my scene and limit user of putting models on scene? I can see memory usage on debug navigator but can’t get values of using memory in realtime.

Hi @michael_nechaev, it sounds like it could be a memory issue. The sample code below would be to free up memory of the SCNNode after setting its geometry property to nil before letting Swift de-initialize it. Maybe try freeing up the memor of nodes that are not in use.

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
    }
}

This topic was automatically closed after 166 days. New replies are no longer allowed.