Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory: object not release after view controller dismiss, with ARC

I have 2 view controller,

FirstViewController - > SecondViewController via

[self presentViewController:SVC animated:YES completion:nil];

memory graph

on SecondViewContrller when I do

[self dismissViewControllerAnimated:YES completion:nil];

enter image description here

My question is, Why is the objects not release on secondViewController after I dismiss this viewcontroller. As you can see on the graph It didn't go down after dismiss. BTW whats the best way to release/dismiss a ViewController?

[EDIT]

I NSLog a message on dealloc method on every VC, When I start from FVC->SVC->[dismiss SVC]. this is my logs

enter image description here

like image 700
Bordz Avatar asked Nov 29 '13 07:11

Bordz


1 Answers

This can be pretty rough stuff. I had similar issues before. Search your code and see if you have strong or wrong references to objects.

One of my top mistakes (and what I have seen on the internet hundreds of times) are delegate properties. I wrote them like @property (nonatomic, retain) id<protocol>delegate; for quite a long time as I realized that if I do so, the delegated object does not get released. One have to use assign in this case.

Hope that help you...

like image 87
Julian F. Weinert Avatar answered Oct 05 '22 01:10

Julian F. Weinert