Getting crash after picking images from UIImagePickerController (Related to memory leak?)

后端 未结 1 1219
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 06:55

I have been trying to minimize my memory footprint with UIImagePickerController, but I\'m starting to think that the memory problems I am having are resulting from

相关标签:
1条回答
  • 2021-01-21 07:13

    Memory warnings are extremely common when dealing with the UIImagePickerController. This is especially true when using the camera. Keep in mind that while a JPG or PNG on disk may only amount to a few MB, the uncompressed in memory bitmap used to draw the image uses considerably more.

    There's nothing that you're doing wrong necessarily, but some improvements can be made:

    Rather than storing the image bytes in Core Data, why not write the image to disk and store the path to the file in your database?

    Rather than using so many autoreleased images, can you find a way to manage their lifecycle directly and release them sooner?

    Your best bet may be to write the images to disk as soon after processing as possible and free up the memory they're using. Then store their location using Core Data rather than the raw data.

    0 讨论(0)
提交回复
热议问题