3

I have a problem in my apps that its memory increase constantly. So here is my app structure. I am using SWrevealViewController for slidemenu.

Slidemenu
    - View Controller A
    - View Controller B
    - View Controller C

My View Controller A consist of UICollectionView and ScrollView. When I perform segue from View Controller A to View Controller B, the memory is doing fine. But if I am going to View Controller A with slide menu, the memory increases. Here is my didSelectRowAtIndexPath on SWRevealViewController's table delegate. I am using performSegueWithIdentifier

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if isLoggedIn {
        self.performSegueWithIdentifier(idSegueLoggedIn[indexPath.row], sender: self)
    }
}

Then I am going to View Controller B via slide menu and then going to View Controller A again, on that point memory increases constantly.

It looks like my View Controller A that consist of UICollectionView doesn't release its object on memory. But if I remove my UICollectionView, my memory issue was dissapear and it runs well.

So I think it was about my reference to UICollectionView. I already declared that with weak property but it does nothing.

@IBOutlet weak var othersCollectionView: UICollectionView!

I try to called deinit() in my View Controlle A but it doesn't called.

Here is my memory usage graph, on each "black arrow", I move to View Controller A with slide menu.

Pls let me know if I am doing something wrong. Thank you so much. Memory Usage

Sonic Master
  • 1,238
  • 2
  • 22
  • 36
  • Try to implement deinit() in ViewController A and then go to ViewController B through side menu, if it is not called then your class is still in stack. Again go to ViewController A from side menu and check whether viewDidLoad() gets called in ViewController A again. If so then your class is loaded twice. – sinner Aug 24 '16 at 10:04
  • I declared `deinit{print("deinit vc A")}` on View Controller A and moving from A to B to A to B to A to B ad so on but it never get called. – Sonic Master Aug 24 '16 at 10:09
  • deinit() will be called only if A gets remove from stack. In current case when user move from class A to B, the class A still remain in the memory. – sinner Aug 24 '16 at 10:31
  • That is my question. My stack never get decreased with SWRevealViewController on View Controller with UICollectionView – Sonic Master Aug 24 '16 at 10:33

1 Answers1

0

I am answering a bit late but I had a similar problem. I the end my problem was linked to the declaration of delegates in some UITableViewCell. I fixed the problem by declaring the delegate variable as weak.

Here is an example :

class MyTableViewCell: UITableViewCell {

@IBOutlet weak var myNameTextField: UITextField!

weak var delegate: CellDbErrorDelegate?