Search code examples
iphonememory-managementmemory-leaksviewdidunload

Where to release all my views if i received memory warnings?


If I am receiving memory warnings where exactly I have to release all my views & data ?

Whether I have to release in

- (void)didReceiveMemoryWarning or in

- (void)viewDidUnload


Solution

  • For iPhone OS 3.0 and later viewDidUnload maybe called during low memory situtations so best to release views in viewDidUnload, just note that for custom views, create them at viewDidLoad instead of init method of the class.

    didReceiveMemoryWarning is used more for releasing custom data structures instead of releasing views.