title: How to clear memory when rendering new image in ARKit?
body: <p>I am working with Swift ARKit for the first time, and in my renderer didUpdate method I provide the user with the option to change the image being rendered.  When they change the image, I create a new image (using a resized image) and use that image for the contents of the faceGeometry node.  The problem is, whenever this occurs, it adds about 50-100mb to the memory use, and if they do it enough times then the app crashes.  </p>
  
  <p>How do I clear the memory for the old images every time I add a new image?  Am I missing a step or should I not be updating/creating an image in the didUpdate method?</p>
  
  <pre><code>func renderer(
      _ renderer: SCNSceneRenderer,
      didUpdate node: SCNNode,
      for anchor: ARAnchor) {
  
      guard let faceGeometry = node.geometry as? ARSCNFaceGeometry,
          let faceAnchor = anchor as? ARFaceAnchor
          else { return }
  
  
      if imageChanged {
          let material = faceGeometry.firstMaterial!
  
              let resizedImg = resizeImage(image: primaryImage!, targetSize: CGSize(width: imageWidth, height: imageHeight))
  
              let expandedSize = CGSize(width: 1000, height: 1000)
  
              let imageOnBlueCanvas = drawImageOnCanvas(resizedImg, canvasSize: expandedSize, canvasColor: .clear, x: imageX, y: imageY)
  
              let v = UIImageView(image: imageOnBlueCanvas)
  
              material.diffuse.contents = v// Example texture map image.
              material.lightingModel = .physicallyBased
  
  
          imageChanged = false
      }
  
  
      faceGeometry.update(from: faceAnchor.geometry)
  
  }
  </code></pre>