IOS memory leak on initialization BufferWithCopyOfBuffer

I found a memory leak when loading an image, but I never found that loops persist on it

enter image description here

enter image description here

enter image description here

enter image description here

code:

class DetailVCHeaderPictuerScrollViewCell: UICollectionViewCell { ... var item: DetailVCHeaderPictuerScrollViewCellItem! { didSet { var ip = indexPath // memory was leak on the follow line DownloadImgOnMain(item.img, { [weak self](img, finished) -> Void in if self == nil { return } if ip == self?.indexPath { self?.imageV.image = img } }) } } ... } func DownloadImgOnMain(url: String, callback: (img: UIImage?, finished: Bool)->Void) { SDWebImageDownloader .sharedDownloader() .downloadImageWithURL(NSURL(string: url)!, options: SDWebImageDownloaderOptions.allZeros, progress: nil) { (img, data, err, finished) -> Void in DispatchBlockOnMainSafe({ () -> Void in callback(img: img, finished: finished) }) } } func DispatchBlockOnMainSafe(b: () -> Void) { if NSThread.isMainThread() { b() } else { dispatch_async(dispatch_get_main_queue(), b) } } 

Or is it a system problem? or language problem?

+5
source share

All Articles