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: 
viewDidUnload is used to release anything that you might have made when the view is created - this included things in viewDidLoad but also includes and IBOutlet properties that are created from inside a xib file. these should all be released and set to nil in viewDidUnload.

Anything else should just be released in dealloc.

The idea is that if viewDidUnload is called to free some memory, the view can be recreated again completely from your viewDidLoad method.

Also see this question;

[memory management on the iPhone with viewDidUnload](https://stackoverflow.com/questions/3490495/memory-management-on-the-iphone-with-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