简体   繁体   中英

High Memory usages and after that app crash ,when using Multiple image selection library in Swift

I am working on multiple image selection, here i used a library BRImagePicker inside project . the issue is that when i start using this libraries functionality it uses memory in high volume and after that app crash with this error message "Message from debugger: Terminated due to memory issue".also checkout the image of memory uses and help me to resolve this issue. 在此处输入图片说明

Since you have not shared any code, I encourage you to read these articles to find the memory leak and/or zombie objects:

Update: The original library is outdated, its last update was 4 years ago and I assume you are porting it to Swift. What Soroush pointed is the what I said earlier. You should not keep a lot of UIImage s in memory, to fix it you need to both keep reference to assets, and unload invisible cells. To get an idea check this library https://github.com/tilltue/TLPhotoPicker .

If you look at the BRPhotoPickerController.m file under Controller group, there is a line:

info.originalImage = [UIImage imageWithCGImage:[representation fullResolutionImage]];

A memory is allocated for each photo/video in the library. This image or video is in its full resolution which means memory will get full within seconds after the picker is presented.
The approach is inappropriate since the original photos/videos are retained in memory.
Instead what you can do is to keep a reference like the media's URL and refer back to it later.
This thread may also be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM