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.

- 314,917
- 42
- 532
- 579

- 904
- 8
- 16
-
Are you keeping several `UIImage`s in the memory? – Maysam Sep 05 '19 at 09:17
-
i am not using uiimage, inside the library used in collection view – Govind Wadhwa Sep 05 '19 at 09:25
2 Answers
Since you have not shared any code, I encourage you to read these articles to find the memory leak and/or zombie objects:
- Find memory leaks in iOS apps with XCode Instruments
- Identifying Memory Leaks using the Xcode Memory Graph Debugger
- Xcode Instruments — Zombies
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 .

- 7,246
- 13
- 68
- 106
-
i have shared the code, please click on the project word in first line you will able to download a demo project. – Govind Wadhwa Sep 05 '19 at 11:41
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.

- 541
- 4
- 17