DeyaEldeen DeyaEldeen - 1 year ago 95
Swift Question

how to make [load on scroll] to not keep adding images into ram?

I'm doing some

load on scroll
in my
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

each entry adds a UITableViewCell with a
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.

Answer Source

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 : example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download