iosmemory-leaksinstrumentsxcode-instruments

Using instruments tool to locate leaks


I am trying to find leaks in my app using the leaks instrument. When the app launches I can see 106 leaks and I am having trouble in finding them.

enter image description here

In the image you can see part of the list, but how can I drill down to the class or line of code that generates the leak?


Solution

  • Finding a leak is not that simple. You need to wear the detective cap, take out your magnifying glass from your coat and start find the trail. i.e.

    For every leaked object there is a responsible library. If it is a UIKit, Foundation or anything low-level, you won't be able to pin point the location of code that is causing the leak since these libraries are in the form of binaries.

    If the responsible library is the one you are writing then you can go to the code by clicking the right method in the stack trace panel on the right. One hint is that the methods listed in the stack trace panel become highlighted if there is a corresponding code available.

    But, since it is not that straight forward, often your own piece of code causes some internal library to leak which is hard to debug. You need to go through some tutorials and practice material before you start. Something certainly not answerable on stackoverflow.