Memory leak from ALAssetRepresentation CGImage in Swift

I am loading images from assets into my UITableView and I noticed that I am getting a CGImage load related memory leak from defaultAssetRepresentation.fullResolutionImage.CGImage.takeunrevededValue.

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(kReviewDisplayCell, forIndexPath: indexPath) as ReviewDisplayCollectionViewCell
    let asset = assets.objectAtIndex(indexPath.row) as ALAsset
    var cgImage = asset.defaultRepresentation().fullResolutionImage().takeUnretainedValue()
    var orientation:UIImageOrientation?
    var orientationValue:NSNumber = asset.valueForProperty(ALAssetPropertyOrientation) as NSNumber
    orientation  = self.correctOrientation(orientationValue)
    var image = UIImage(CGImage: cgImage, scale: 0.5, orientation: orientation!)
    cell.imageView.image = image

    return cell
}

      

According to the memory leak devices, the leak appears to be related to: NSPathStore2 object. Responsible frame:+[NSPathStore2 pathStoreWithCharacters:Length:]

The above function is called earlier on the stack: -[ALAssetRepresentation _fileDescriptor]

then -[PLGateKeeperClient fileDescriptorForAssetURL:]

I'm sorry, I don't have enough reputation to post my screenshot.

The distribution tool always persists the CGImage from the UITableViewController even after the control manager is disabled by the navigation manager and I can't figure out if there is a strong reference to it somewhere. Is there a way to manually release the CGImage link when using ARC? I tried to put the above code in autoreleasepoool {} but it didn't work. Thanks in advance for your help.

+3
ios memory-leaks alasset


source to share


No one has answered this question yet

Check out similar questions:

3044
Making a memory leak with Java
1146
performSelector may leak because its selector is unknown
1042
The result was a leak of the window that was originally added
61
How to detect a cell of a tableView being touched or clicked in swift
1
Use ALAssetRepresentation getBytes: fromOffset: length: error: but with correct orientation
1
UICollectionView width suddenly doubles
1
UICollectionView showing values ​​from old cells when reused
1
Swift bug - using cell implicit type 'cell' - Collection View
1
Adding UICollectionViewController to UIViewController doesn't work
1
How can I optimize loading images from url for uicollectionview?



All Articles
Loading...
X
Show
Funny
Dev
Pics