So I have an UIView that contains an UIImageView with a fairly large image (say 1600x1600). When I load it I can see on Xcode that the memory goes up as expected but still manageable.
Now if I myView.removeFromSuperview()
the memory doesn't go down and if I keep adding and removing the view with the other images one at a time, something like:
- set image
- add it to the view
- remove image from superview
- set another image
- add it to the same view
- back to 3 and continue looping
After every iteration I see that the memory keeps increasing until eventually I run out of memory, receive a memory warning and crash.
Is this expected? shouldn't the memory be released when I remove the image from superview?