title: Memory leak when using UITableView dequeueReusableCell
body: <p>I've checked my app for memory leaks in the instruments "Leaks" tool
  and found about 16 of them on the controller that responsible for the UITableView content.</p>
  
  <p>this is the code -</p>
  
  <pre><code>    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let cell = tableView.dequeueReusableCell(withIdentifier: "clause", for: indexPath) as! CodeOfConductTableViewCell
  
      cell.index.text = String(indexPath.row + 1)
      cell.cocTxt.text = lines["line\(indexPath.row + 1)"]
  
      return cell
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ABI7z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ABI7z.png" alt="enter image description here"></a></p>
  
  <p>when i changed the code to this:</p>
  
  <pre><code>    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let cell = CodeOfConductTableViewCell()
  
      cell.index = UILabel()
      cell.cocTxt = UITextView()
  
      cell.index?.text = String(indexPath.row + 1)
      cell.cocTxt?.text = lines["line\(indexPath.row + 1)"]
  
      return cell
  }
  </code></pre>
  
  <p>no leaks where detected.</p>
  
  <p>what is causing the leaks? am i using it wrong?</p>
  
  <p>I want to use this function since it's better for performance,
  and i want to understand what's wrong here</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>adding cell class code (nothing fancy here): </p>
  
  <pre><code>class CodeOfConductTableViewCell: UITableViewCell {
  
  @IBOutlet weak var index: UILabel!
  @IBOutlet weak var cocTxt: UITextView!
  
  override func awakeFromNib() {
      super.awakeFromNib()
  
  }
  
  override func setSelected(_ selected: Bool, animated: Bool) {
      super.setSelected(selected, animated: animated)
  
  }
  </code></pre>
  
  <p>}</p>