Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ARSKView在关闭ViewController时未释放内存_Ios_Swift_Sprite Kit_Scenekit_Arkit - Fatal编程技术网

Ios ARSKView在关闭ViewController时未释放内存

Ios ARSKView在关闭ViewController时未释放内存,ios,swift,sprite-kit,scenekit,arkit,Ios,Swift,Sprite Kit,Scenekit,Arkit,我正在创建一个使用ARSKView的应用程序。我发现它在关闭ViewController时并没有释放内存。我无法在我的代码中找到任何问题。 这是我使用ARSKView的代码 class ARViewController: UIViewController, ARSKViewDelegate { weak var sceneView: ARSKView? override func viewDidLoad() { super.viewDidLoad()

我正在创建一个使用ARSKView的应用程序。我发现它在关闭ViewController时并没有释放内存。我无法在我的代码中找到任何问题。 这是我使用ARSKView的代码

class ARViewController: UIViewController, ARSKViewDelegate {

    weak var sceneView: ARSKView?

    override func viewDidLoad() {
        super.viewDidLoad()
        sceneView = ARSKView(frame: self.view.frame)
        self.view.addSubview(sceneView!)
        sceneView?.delegate = self

        let scene = CustomScene(size: view.frame.size)
        scene.sceneDelegate = self
        sceneView?.presentScene(scene)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        activateARView()   
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        sceneView?.session.pause()
    }

    var configuration = ARWorldTrackingConfiguration()
    func activateARView() {
        configuration.worldAlignment = .gravityAndHeading
        sceneView?.session.run(configuration)
    }

}

控制器刚刚暂停,您可以尝试将控制器设置为“nil”,只需确保在此之前清除所有依赖项。

您的场景保持在视图控制器上,视图控制器的视图保持在场景上。ARC无法将VC引用计数降到0到0release@Knight0fDragon你能具体说明一下吗,代码中的问题在哪里?已经告诉yousceneDelegate很弱。@Knight0fDragon apple已经在iOS 12中解决了这个问题。一旦设置为零,恐怕就没有别的事可做了,只能等待iOS释放内存。如果是在Xcode中,您正在监视内存分配,那么可能是Ccode问题