views:

650

answers:

3
-(id)viewWillDisappear:(BOOL)animated
{
report_memory_str(@"BEFORE RELEASE viewWillDisappear");
self.view = nil;
report_memory_str(@"AFTER RELEASE viewWillDisappear");
}

When my view Disappear, i try to release current view before push to another controller, i don't get more free memory, why ? How to get more free memory ?

2009-08-10 09:51:31.263 App[4622:207] BEFORE RELEASE viewWillDisappear -- Memory in use (in bytes): 7880704
2009-08-10 09:51:31.280 App[4622:207] AFTER RELEASE viewWillDisappear -- Memory in use (in bytes): 7884800
A: 

I would release the view in viewDidDisappear: instead of viewWillDisappear:. If the change is animated, the view will be needed before it can be deleted. I'm not sure whether the superview retains and releases it's subviews, but this could be the reason, why your view wasn't instantly deleted when it is still in the view hierarchy.

You could try

  • Checking the used memory a few seconds later.
  • Run with the Leaks Performance Tool to see whether the object gets released or leaks.
  • Check that you actually release the view in its accessor method.
Christian
it's better to use viewDidDisappear than viewWillDisappear !memory it highter later because i load many thing on the new controler.No Leaks.
NSchubhan
A: 

Is it working or not?

sandy
A: 

just because you call release, doesn't mean the object has been deallocated. If the retain count is 0 it is marked for deallocation. Perhaps put a breakpoint on your dealloc of the object you are trying to release and see if it is being called before or after your memory check.

maxpower