O'Reilly logo

Xcode 4 iOS Development by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Detecting a memory leak

Memory leaks are a very serious type of bug that the static analyzer can help you discover. As you can see in the following screenshot, the analyzer has detected a potential memory leak for the instance of NSString.

If your project does not release objects which have been declared from memory, you are opening the doors to some serious issues which can affect your application, and make it run out of memory very quickly which may result in your application crashing. We will take a look at an example and add some code to our project to show you how memory leaks occur:

  1. Firstly, open the file main.m located within the Supporting Files folder of your project, and add the following code as shown in the snippet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required