title: How to deallocate RealityKit ARView()?
body: <p>I cannot manage to release my RealityKit <code>ARView()</code> from memory.</p>
  
  <p>I am aware that there are (were?) similar issues with ARKit + SceneKit – with workarounds like this one: <a href="https://stackoverflow.com/a/53919730/7826293">https://stackoverflow.com/a/53919730/7826293</a>
  which doesen´t solve my problem unfortunately.</p>
  
  <p>The solutions above kind of work by removing everything "suspicious" manually. That is exactly what I did in a even wider scope:</p>
  
  <pre><code>class ViewController_ARViewMemoryTest: UIViewController {
  
      var arView: ARView?
  
      init() {
          super.init(nibName: nil, bundle: nil)
          arView = ARView(frame: .zero)
      }
  
      required init?(coder: NSCoder) {
          fatalError("init(coder:) has not been implemented")
      }
  
      deinit {
          doEverythingThatsNeeded()
      }
  
      public func doEverythingThatsNeeded() {
          self.arView?.session.pause()
          self.arView?.session.delegate = nil
          self.arView?.removeFromSuperview()
          // Quite a few more removals and resets here, ie. for Combines AnyCancellables
          self.arView = nil
      }
  
  }
  </code></pre>
  
  <p>I am calling doEverythingThatsNeeded() from outside as well:</p>
  
  <pre><code>aRViewMemoryTest?.doEverythingThatsNeeded()
  aRViewMemoryTest?.arView = nil
  aRViewMemoryTest = nil
  </code></pre>
  
  <p>The issue seems to be independent from the fact that I have wrapped my ARView or alternatively a UIViewController in a SwiftUI <code>UIViewRepresentable</code> / <code>UIViewControllerRepresentable</code>.</p>
  
  <p>I believe it must be a bug and I have filed a report months ago. However I am hoping for workarounds that help until Apple fixes the potential issue.</p>
  
  <p>Thanks a lot!</p>