Memory warning in Xamarin iOS while loading multiple images in UIView

892 Views Asked by At

I'm working on Xamarin iOS project. I have to load the images depends on help menu choice. I have a view controller with UIImageView and every time I'm adding the list of images I have to show a list and showing the Images. It works fine for two or three menu options (times). After few clicks app is crashing due to memory. I tried to clear the List on Close button click even though it is crashing. Can you please help me to resolve this issue.

Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

You need to be careful with adding "heavy" resources like images. Rule of thumb:

  1. Keep only in memory what you really need, means: clean up everything that's not in the view port. Use UICollectionViewor UITableView, they support dequeueuing reusable cells (see Xamarin docs for more information).

    1. Clean up everything you don't need anymore. Make sure it's cleaned up for sure.

For some more information, see here: https://thomasbandt.com/xamarinios-memory-pitfalls