I saw a message in the Xcode console which is Received memory pressure event 1 vm pressure 0
. I'm not really sure what causes this and why but I do know this prints when I'm in a camera viewcontroller. I'm guessing it's nothing to worry about (yet) but is it pointing to something I should fix asap?
FirstViewController: UIViewController {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[UIImagePickerController.InfoKey.editedImage] as! UIImage
let croppedImage = cropToBounds(image: image, width: 10, height: 10)
self.productImage.image = croppedImage
print("size: \(croppedImage.size)")
print("original size: \(image.size)")
self.dismiss(animated: true, completion: nil)
}
func setupCameraPicker() {
if UIImagePickerController.isSourceTypeAvailable(.camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera;
imagePicker.allowsEditing = true
self.present(imagePicker, animated: true, completion: nil)
}
}
}
autoreleasepool
autoreleasepool {
let image = info[UIImagePickerController.InfoKey.editedImage] as! UIImage
let croppedImage = cropToBounds(image: image, width: 10, height: 10)
self.productImage.image = croppedImage
print("size: \(croppedImage.size)")
print("original size: \(image.size)")
self.dismiss(animated: true, completion: nil)
}
Try to put your code in autoreleasepool Foundation’s NSAutoreleasePool type, later abstracted to the @autoreleasepool block, is a very old concept in iOS development. During the Obj-C era of iOS, usage of this type was important to prevent your app's memory from blowing up in specific cases. As ARC and Swift came around and evolved, very few people still have to manually play around with memory, making seeing it become a rare occurrence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With