I know my question is simple and I know many question on that topic but I can't find any solution to it.
I have simple table view only have the label for 100 rows. When I scroll the memory is increasing every time I scroll using the instrument tool in the Xcode although I use the dequeuing cell as apple documentation my question why the cells not releasing from memory (free from memory) every time I scroll it's creating new cell.
The following my code:
import UIKit
class ViewController: UIViewController ,UITableViewDataSource,UITableViewDelegate{
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = "Table View Cell! "
return cell
}
}
You can check the instruments tools and you can see the memory increasing every time you scroll.
Please, how can I release cells from memory when I'm scrolling?
Thanks a lot.