Code snippet:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: BroadCastFeedTableViewCell = broadCastTableView.dequeueReusableCell(withIdentifier: "broadCastFeedCell") as BroadCastFeedTableViewCell
cell.singlePicImageView.kf.setImage(with: URL(string: (self.broadCastArray[indexPath.row].images_url?[0])!), placeholder: nil, options: nil, progressBlock: nil)
{ (theImage, error, cache, url) in
if theImage != nil{
let imageHeight = self.getAspectRatioOfDownloadedImages(resolution: self.broadCastArray[indexPath.row].image_resolution![0])
cell.collectionContentViewHeightConstraint.constant = imageHeight
cell.layoutSubviews()
cell.layoutIfNeeded()
}else {
let placeHolderCenterCordi = UIView().getViewRelationWithSuperSuperView(viewControllerView: cell.collectionContentView,
subView: cell.singlePicImageView, subObjFrame: cell.singlePicImageView.frame)
cell.singlePicImageView.addPlaceHolderImageView(cordinates: placeHolderCenterCordi.center)
}
self.broadCastTableView.rowHeight = UITableViewAutomaticDimension
}
}
In above code I have used Kingfisher library to load image from remote server, whenever following code load certain images(GIF, JPEG, PNG) which may have large size (2-5 MB approx.) the app terminates due to memory issue. In iPhone 5s it terminates instantly as soon as app is launched and in other iPhone Model (7, 6s) it terminates after scrolling for certain amount of time. I have also check Allocation and leak but I didn't understand/found much about the issue.
I have also attached the profiling graph. This shows there is no such memory leaks, but due to some issue app is terminating: