I cannot manage to release my RealityKit ARView()
from memory. I am aware that there were similar issues with ARKit + SceneKit with workarounds which doesn't solve my problem, unfortunately.
The solutions above kind of work by removing everything "suspicious" manually. That is exactly what I did in an even wider scope:
func closeCurrentView(completion: (() -> Void)? = nil, isScanAnotherFloor: Bool = false) {
if backgroundRenderingID != UIBackgroundTaskIdentifier.invalid {
let app = UIApplication.shared
app.endBackgroundTask(self.backgroundRenderingID)
self.backgroundRenderingID = UIBackgroundTaskIdentifier.invalid
}
self.arView?.session.pause()
self.arView?.session.delegate = nil
self.arView?.scene.anchors.removeAll()
self.arView?.removeFromSuperview()
self.arView?.window?.resignKey()
self.arView = nil
}
Memory will rise to 90MB to 250MB and once deinit
is called it will reduce to 175MB, not clearing all the memory.
Also at the time of initializing, I set proper options too.
arView?.renderOptions = [
.disableMotionBlur,
.disableDepthOfField,
.disablePersonOcclusion,
.disableGroundingShadows,
.disableFaceOcclusions,
.disableHDR
]
But still no luck.