1

Is there any way to check/debug memory leaks and any memory related crash by changing few Build settings? It would be better if I get any memory warnings.

aparna
  • 353
  • 2
  • 3
  • 13
  • it is for iOS.. I m sorry.. – aparna Jul 04 '13 at 11:13
  • 1
    For crashes due to bad memory access set [`NSZombieEnabled`](http://stackoverflow.com/a/4917557/1407017) flag in build scheme. To check/fix memory leaks you need to profile the build using [Instruments(Leaks, Allocations etc.)](http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode) in XCode. – Amar Jul 04 '13 at 11:32
  • You can run Product->Analyze to pick up certain mistakes, or use Instruments' Allocations and Leaks tools to diagnose memory problems. And use ARC. – Mike Weller Jul 04 '13 at 11:32

1 Answers1

2

When your application gets a memory warning, the following method is called. In this method you can deallocate any views or object instances that you are not using anymore to clear memory.

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; 
}

You can check for memory leaks using the leaks instrument in Xcode. It is the best way. You can also check for memory allocations and whether memory is deallocated properly using allocations tool. Else, the simplest way is to run your app and check the app's memory usage in the activity monitor. This method can be used to find out where you are allocating maximum memory. Also you can run "analyze" by holding the run button. It will also help you find memory leaks.

prince
  • 854
  • 2
  • 9
  • 36
  • 1
    thanks all. I already use ARC and analyze before running the app. To reduce other memory leaks and to know about memory status I will use instruments tool and also didReceiveMemoryWarning function if needed. – aparna Jul 04 '13 at 11:48