I'm doing some load on scroll
in my UITableView
to fetch data from the server.
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)
{
let lastElement = self._titles_en.count - 1
if indexPath.row == lastElement
{
page += 1
searchForString()
}
}
each entry adds a UITableViewCell with a UIImageView
loaded using kingfisher
loadRemoteImage(placeImage, argURL: _images[indexPath.row], cr : 0)
Now my question is, how do I make sure that the ram used don't keep on increasing?
I was watching the ram in debug tools, it increases by 10 mega bytes for about 3 page loads, which is too much, and it's starting to exceed 200 mega bytes, so is there any trick to avoid this ram open increase? I'm afraid of the user keeping scrolling many times and boom, app crash.
I'd say optimize your images, a lot. According to what you're saying, you're using very large images. Remember that they are being displayed in a UITableViewCell, so it should be safe to have them compressed.
Try fetching and displaying thumbnails instead of the actual full-sized images. That would improve user experience too, reduce lag, your memory usage!
You can use AsyncDisplayKit and automatically benefit from intelligent preloading and memory management. In particular, if a cell of an ASTableNode
includes an image, but that cell is not likely to be visible soon then the image will be purged from memory.
example :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With