HelloimDarius HelloimDarius - 5 months ago 57
iOS Question

Memory Management (UICollectionView with images)

I have a navigation bar and 2 views. One view has a button which shows UICollectionView with images loaded from URL. Let's say I have 10 mb memory at app start. Clicking a button shows images and a total of 30-40 mb. Once clicking "Back" and leaving collection view shows 20 mb memory usage and after clicking multiple times back and forth never goes back to the initial 10 mb.

Do I have to be concerned about it?

Why can't I go back to the initial state of 10mb ?


Image loading normally uses a cache. Specifically the imageNamed call caches the images in case you use them again. (See the docs on imageNamed for more info.)

As Jean-Baptiste says in his comment, the image cache will be flushed automatically if memory gets low.

If you repeatedly go to your collection view, press back, and re-visit your collection view and your memory footprint increases each time then you likely have a problem, but it's common to have your memory use climb from it's "low water mark" after launch and never go back to that low point.