UITableView not scrolling smoothly with large dataset in iOS 17 when using custom cells
I'm having trouble with I've tried everything I can think of but I'm optimizing some code but I'm experiencing performance issues with a `UITableView` that displays a large dataset (over 10,000 items) using custom cells in my iOS 17 app... The scrolling is noticeably laggy, which affects the user experience. I've tried implementing cell reuse properly, but it seems like the lag persists, especially when scrolling quickly. Here's a snippet of my table view setup: ```swift class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var items: [MyCustomModel] = [] // Assume this contains over 10,000 items @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self tableView.register(MyCustomCell.self, forCellReuseIdentifier: "cell") } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return items.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyCustomCell let item = items[indexPath.row] cell.configure(with: item) // Custom method to configure cell return cell } } ``` I've also enabled `tableView.estimatedRowHeight` and set it to a realistic value, but that didn't seem to help either. Moreover, I've tried profiling with Instruments to check for any memory issues or bottlenecks, but everything seems to be in order. I suspect that the issue might be related to the way I'm loading images in the cells; they're being loaded synchronously from the disk, which could be slowing down the scrolling. To mitigate this, I tried using `SDWebImage` for asynchronous image loading, but the performance improvements were minimal. Here's how I'm currently loading images: ```swift class MyCustomCell: UITableViewCell { @IBOutlet weak var myImageView: UIImageView! func configure(with model: MyCustomModel) { myImageView.sd_setImage(with: URL(string: model.imageUrl), placeholderImage: UIImage(named: "placeholder")) } } ``` Has anyone encountered similar issues with `UITableView` in iOS 17? What best practices can I apply to improve the scrolling performance for large datasets? Any suggestions would be greatly appreciated! The stack includes Swift and several other technologies. Has anyone else encountered this? I've been using Swift for about a year now.