How to clear memory after UIImageView.animationImages?

I've created a new Xcode project that has only the following:

  • code creating an array of UIImages from png's dragged in to the project (I have tried both UIImage(named:) and UIImage(contentsOfFile:) when appending images to the array)
  • a UIImageView
  • a button which sets the imageView.animationImages = arrayOfImages and calls imageView.startAnimating()


When the button is pressed and the animation plays, the memory usage increases by 150-200MB, depending on the number of images in the image array. Then the memory usage remains at that level.


Setting imageView.animationImages = nil doesn't clear the memory. Triggering a low memory warning doesn't clear the memory. This same behavior is seen both in the simulator and on device.


How could I go about clearing that memory? Any suggestions would be helpful. Thanks!

Accepted Reply

Although the memory hit doesn't occur when assigning the images to an array, and the memory hit only happens once the animation is played, still the only way to reclaim the memory seems to be removing all references to the image array by setting both the variable array and the animationImages property on the UIImageView to a blank array.


imageArray = []
imageView.animationImages = []

Replies

Although the memory hit doesn't occur when assigning the images to an array, and the memory hit only happens once the animation is played, still the only way to reclaim the memory seems to be removing all references to the image array by setting both the variable array and the animationImages property on the UIImageView to a blank array.


imageArray = []
imageView.animationImages = []