The memory used jumps to 498 megs when image is loaded but not displayed and drops to 242 megs when viewcontroller is dropped with nav controllers back button.
UIImage(contentsOfFile: is not supposed to cache, i assume that is where the 240 meg drop is from, but why is half of memory used, 240 megs, being retained?
func save_ImageJPG() -> Bool {
// load tif from app folder image approx 8000 x 6000 pixels let s = currentMap_Name.replacingOccurrences(of: " ", with: "%20")
let filePath = getDocumentsDirectory().appendingPathComponent("Folder" ).appendingPathComponent(s)
let image = UIImage(contentsOfFile: filePath.path) // change file type to jpg let f = URL(string: s)?.deletingPathExtension().absoluteString
let e = URL(string: f! + ".jpg")?.absoluteString let path = getDocumentsDirectory().appendingPathComponent("TempFolder" ).appendingPathComponent(e!)
if !FileManager.default.fileExists(atPath: path.path) { let jpgData = (image!.jpegData(compressionQuality: 1.0)!) try? jpgData.write(to: path) return true } return false }
or is the let jpgData = (image!.jpegData(compressionQuality: 1.0)!) retaining memory?