How to find out exactly where a memory leak occurs in an iPhone project

When developing applications in Xcode, a memory leak occurs. When I tested them in an extended detailed view, they show different methods that are not related to implemented ones. How to find out exactly which object is flowing and where it is flowing.

When ARC is on, should we care about memory leak or not?

+7
source share
2 answers

Even with ARC memory leak can occur, it just inserts the release and autorelease at compile time.

1. You must check for leaks using Build and analyze in Xcode, shift+command+b , you must clear these problems.

2. After that, you can start using the tools using the profile option command+i . This will tell you where the leak may occur.

This link will also help you http://soulwithmobiletechnology.blogspot.in/2011/04/how-to-check-memory-leaks-in-xcode-4.html

Edit: Added some screenshots that I hope will make it clear.

During profiling, after selecting leaks select the call tree option and check the hide system libraries , invert call tree and show obj-c only checkboxes, as shown in the figure below.

After double-clicking on the name of the character below, you will get the line in which it flows. enter image description here

You will get something like this.

enter image description here

+11
source

Yes, even with ARC there are memory leaks . ARC is not a garbage collector, it only inserts for you, at compile time, saves, releases and auto-implements in key positions. Therefore, although this helps the developer, you should be aware that memory leaks still exist (e.g. circular references). You can start by using the Static Analyzer and fix any problem that it shows you. Then you can go to Tools and select Leaks .

+10
source

All Articles