Question: I am new to iPhone development. 

I am using some buttons and labels in my app. I am releasing all these buttons and labels in dealloc function.  

I am also releasing them in viewDidUnload.

```
- (void)viewDidUnload
{
[super viewDidUnload];
self.ans1 = nil;
self.ans2 = nil;
self.ans3 = nil;
self.ans4 = nil;
self.button = nil;
self.button2 = nil;
self.button3 = nil;
self.button4 = nil;
}

```

I just want to know that it is good for memory management or it makes no difference to memory management.  

And why we use that?? 

Thanks in advance..!!

Answer: 
it is not the view controller that is unloaded when viewDidUnload is called but only its **view**. **The view controller stays alive until it is deallocated.**

In viewDidUnload, you have to release those objects that are part of the view and everything that can and will be recreated in viewDidLoad (because viewDidLoad will be called again when the view controller need to recreate its view). This includes all your outlets. You also have to set these variables to nil to avoid overreleasing them.

Because in dealloc, you should release all objects your view controller retains, including those you included in viewDidUnload.
It is good for memory management. If you release objects associated with a View controller when the controller unloads, you effectively reduce the memory footprint of your application. Retaining objects even when you are not using them makes your application more prone to memory warnings & eventual termination. 

Hence, it is good practice to allocate in `ViewDidLoad` & release in `ViewDidUnload`.

HTH,

Akshay