I use a carousel to display local images in my application.
Every time I reload the view, I can see the "Distribution" tool on the "Tool", which my application allocates memory for images, but never released it.

Below you can see the code:
func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, var reusingView view: UIView!) -> UIView! { if view != nil { for subview in view.subviews { if let imageView = subview as? UIImageView { imageView.image = nil } subview.removeFromSuperview() } } let newView = UIView(frame: aFrame) self._getImageFromLocalWithPath(aPath, completion : { image in if image != nil { let imageView = UIImageView(image: image!) newView.addSubview(imageView) } } ) return newView } private func _getImageFromLocalWithPath(imagePath : String?, completion : UIImage? -> Void) { autoreleasepool { ALAssetsLibrary.defaultAssetLibrary().assetForURL(NSURL(string : imagePath!), resultBlock: { asset in weak var wasset = asset if wasset != nil { let image = UIImage(CGImage : wasset?.defaultRepresentation().fullScreenImage().takeUnretainedValue())
I already found topics about this problem, but I still have my problem:
Any suggestion?
source share