I have a long horizontal paged scrollview, for each page, I put a fullscreen UIImage.
As it is expensive and not necessary to add all UIImage at once, currently I lazy load the images (pageIndex-1 + pageIndex + pageIndex+1 ‘s images, using NSOperationQueue FYI), and remove all other UIImageViews.
The memory usage reported from Instrument is acceptable with normal usage, but I discover if I keep scrolling (switching between 30 pages continously), the Dirty memory would keep increasing, especially “Memory Tag 70” which I believe it is the raw data from UIImage. Once I stop touching the app for 3~4 seconds, ALL “Memory Tag 70” would be released automagically.
I’ve put NSLog in several places and I’m sure the UIImageViews are removed from its superview when it is out of the “display range”.
Is scrolling preventing the main loop to release those memory? What could I do to prevent such condition? Thanks!
p.s The huge drop in Dirty Size is the moment when I stop scrolling.
(Just a guess, I’m far from an Xcode to test it, and assuming a non-ARC environment)
Instead of
[otherImageView removeFromSuperview], you can useTo avoid the image going to the autorelease pool.