I have an app that consist of collectionview with 30 cell. Its cell consist of image and label. My problem is, when I load that image my memory use going 87 Mb. But if I didn't set that image, my memory use is only 30 Mb.
I am using Moa to load image asynchronously. And here is my cell init:
import UIKit
import moa
class ProductListItemCell: UICollectionViewCell {
@IBOutlet var imgProductItem: UIImageView!
@IBOutlet var titlleProductList: UILabel!
@IBOutlet var priceProductList: UILabel!
@IBOutlet var boldPriceProductList: UILabel!
func updateContent(product: Item) {
// if let imgUrl = product.picUrl {
// self.imgProductItem.moa.url = "http:\(imgUrl)"
// }
if let title = product.title {
self.titlleProductList.text = title
}
if let price = product.priceTag {
self.priceProductList.setStrikethrough(price)
}
if let boldPrice = product.price {
self.boldPriceProductList.text = boldPrice
}
}
}
And here is my cellForItemAtIndexPath
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if collectionView == myItemsCollectionView {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("firstCell", forIndexPath: indexPath) as! myCollectionViewCell
cell.updateContent(self.myItems.items[indexPath.item])
return cell
}
else {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("othersCell", forIndexPath: indexPath) as! myCollectionViewCell
cell.updateContent(others[indexPath.section].items[indexPath.item])
return cell
}
}
Is there any way to download image and "compress" it? Or Am I doing it wrong? Pls let me know. Been stuck at this point for a weeks.
Note: How many memory use standard for some apps with collectionview like my apps? Does 30Mb is belongs to "high"? I am newbie in memory management.
Thank you so much.