IPad iOS memory management - how to free up "real memory" used by UIImageViews, UIScrollViews?

I have memory problems in one of my applications, and I have identified “Real memory” as defined in “Tools”> “Activity Monitor” as a possible culprit.

My application highlights large UIImags in UIScrollViews . There CIImageFilter is applied to one of the images. The activity monitor shows that when you first click on a view controller that contains scrolling with large images, the use of real memory approaches 300 MB. Subsequent clicks / tooltips raise it to approximately 500 MB:

I read that "Live Bytes" does not take into account the memory used by textures and CALayers, so my question is: How to properly free the memory that CALayers used in my image / Scrollviews?

See the real usage area of ​​the blue memory usage chart on the right:

enter image description here

Both real and virtual memory are the highest for this process:

enter image description here

My concern is that I try to clear my large scrolls and images when this controller appears, and the numbers for live bytes drop to about 5 mb, and the real memory remains outrageously high (~ 500 mb):

ContainerScrollView* container = ...; [container.view removeFromSuperview]; container.view = nil; 

Here's the distribution profiling: enter image description here

+6
source share
1 answer

I found a person experiencing a similar problem:

Mysterious CoreImage memory leak using ARC

The answer (I really hope so) will start using NSData dataWithContentsOfFile: and then create a UIImage imageWithData: Got the image that the user selected? Write it to a temporary file and read it. I don’t trust any other image methods, because they seem to behave irrationally in iOS 6.1.2 for large images over 12 hours of testing.

+1
source

All Articles