ARView doesn't deallocate after dismiss

242 views Asked by At

I'm facing an issue with the RAM management on the view which uses Reality Kit. There I have a simple code that reproduces the issue. Before open AR view the app takes about 70MB of RAM, after running AR view, then it takes about 450MB RAM, but when I dismiss the AR, then the whole app takes about 250MB RAM, so it's like 130MB more of unused data from AR. https://i.stack.imgur.com/3oQym.png how I can clean that? I used Xcode tools to detect leaks, but on that tool everything is okay. How I can solve it?

override func viewDidLoad() {
     super.viewDidLoad()
     arView = ARView(frame: self.view.bounds)
     self.view.addSubview(arView!)
     self.view.sendSubviewToBack(arView!)
}

@IBAction func dimissTapped(_ sender: Any) {
     self.arView?.session.pause()
     self.arView?.session.delegate = nil
     self.arView?.scene.anchors.removeAll()
     self.arView?.removeFromSuperview()
     self.arView?.window?.resignKey()
     self.arView = nil
     self.dismiss(animated: true, completion: nil)
}


  [1]: https://i.stack.imgur.com/3oQym.png
0

There are 0 answers