tags:

views:

41

answers:

2

Hello all,

I want to know if there is any tutorial provided by apple people or any blog where I can learn how to deal with memory and view releasing when you get didRecieveWarning in iPhone.

A: 

I’d definitely read through Apple's Memory Management Programming Guide for Cocoa if you’re new to Cocoa programming and for general memory management topics.

Specific to your question, when you get a didReceiveMemoryWarning message, you’ll want to release anything that you’re not using. If you have any cached objects or view controllers, release them (just make sure that when they need to be used again they’re reloaded). In general, something that’s expensive to get again, such as resources downloaded from the Internet, should be the last thing that you release so that the user doesn’t have to download it again.

Jeff Kelley
+1  A: 

With the advent of -viewDidUnload in 3.0, you should do more of your discarding of objects there. It seems like yet another -dealloc, except that you may want to keep some objects that are expensive to recreate and won't want to release those.

mahboudz
I would just add that the main thing there is to clear out any IBOutlets you have (if you have an IBOutlet you are releasing in dealloc, release it there too and set the reference to nil). In general cleanup of heavier objects should be done in didReceiveMemoryWarning, because the viewDidUnload might be called in cases other than memory warnings.
Kendall Helmstetter Gelner