Photos in tableView from local gallery uses too much RAM
<p>When I try to get photos using a URL from a local gallery I add them to a tableView using <code>ALAssetsLibrary()</code></p>

<p>My code:</p>

<pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {

    var cell: AllPhotosTableViewCell!
    cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! AllPhotosTableViewCell

    let url = array[indexPath.section]["photos"] as! [AnyObject]

    if let image = cachedImages[url[indexPath.row] as! String] {        
        cell.imageViewImg.image = imageResize(image, sizeChange: CGSize(width: 50, height: 50))
    } else {

        let nsURL = NSURL(string: url[indexPath.row] as! String)!
        var loadError: NSError?

        asset.assetForURL(nsURL, resultBlock: { (asset) -&gt; Void in

            if let ast = asset {
                let image = UIImage(CGImage: ast.defaultRepresentation().fullResolutionImage().takeUnretainedValue())
                self.cachedImages[url[indexPath.row] as! String] = image

                dispatch_async(dispatch_get_main_queue(), {

                    cell.imageViewImg.image = self.imageResize(image, sizeChange: CGSize(width: 50, height: 50))

                })
            }
        }, failureBlock: {(error) -&gt; Void in
            loadError = error
        })
    }

    return cell
}
</code></pre>

<p>I try to minimize the size of photos, it helps a little but it doesn't solve the problem if I need to use many photos (10 or more...)</p>