my project use ARC
, and when i have to show a view with navigation controller i do this:
ShareViewController_iPhone *share = [[ShareViewController_iPhone alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil];
[self.navigationController pushViewController:share animated:YES];
and i can see in xcode that the memory is increased of a certain value, then when i dismiss the view i do this:
[self.navigationController popViewControllerAnimated:YES];
but when the view is closed, the memory doesn't decrease, how i can do it?
ARC will clean the memory on its own cycle (it will collect all the objects whose reference count set to "0" means who are ready for deallocation), we can't control this. It is managed by the operating system.
So when you are popping a view controller, it doesn't deallocate it from the memory immediately. It can take time depending on the other memory usage/memory availability.
One more case, you need to check if on every push the memory allocation is increased by a certain value, then there will be definitely something wrong in your code.
When you pop a ViewController and it don't release, it means have a reference cycle in your controller. You must check delegate if have, block, weak, strong reference.
Hope these information will help you. :)
When you pop the viewcontroller, it is marked for deallocation (i.e it's reference count becomes 0 unless referenced by another object). but not deallocated immediately. Deallocation as far I have seen is mostly random!
The view controller here must be retained for a while by the navigation controller itself to create the animation. The deallocation does happen immeadiately after the reference count drops to zero. Try to pop the view controller without animation (e.g.
animated:NO
) and see for yourself if the deallocation happens right away.