Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the line of memory leak in Instruments

I am new to Instruments in iOS. I am trying to find the memory leak in instruments and using Xcode 4.5.2 and following this tutorial: http://soulwithmobiletechnology.blogspot.sg/2011/04/how-to-check-memory-leaks-in-xcode-4.html.

I am able to find the memory leak and able to press the arrow to go to history of the memory leak item. But when i double-click any of them, it doesn't show the line it is causing the memory leak.

The image is like this:

enter image description here

What am i doing wrong? Need some guidance... Thanks..

like image 468
lakshmen Avatar asked Feb 05 '13 10:02

lakshmen


People also ask

How do you find memory leaked instruments?

Diagnose the Memory Leak Now, it's time to open the leaks instrument: Choose “Xcode” in the top left of the screen. Expand “Open Developer Tool,” and select “Instruments” Now choose “Leaks,” and make sure you have chosen your target app and device at the top (“Choose a profiling template for…”):

How do I find a memory leak in production?

The best approach to checking for the existence of a memory leak in your application is by looking at your RAM usage and investigating the total amount of memory been used versus the total amount available. Evidently, it is advisable to obtain snapshots of your memory's heap dump while in a production environment.

Where are memory leaks found?

Where are memory leaks found? Explanation: Memory leaks happen when your code needs to consume memory in your application, which should be released after a given task is completed but isn't. Memory leaks occur when we are developing client-side reusable scripting objects.


1 Answers

I had trouble finding it at first too. Here's how:

  1. Select the Leaks instrument (obviously).
  2. Show the "Extended Detail" Pane by clicking the Icon in the toolbar that toggles it from the right.
  3. Select Your leaked item from the list.
  4. Double Click on the entry there you see your Application Name and/or one of your Classes, which has a User Icon next to it to take you to the problematic code. (There can be more than one)

enter image description here

Double clicking that (4), will take you directly to the file, and line of code in question:

enter image description here

like image 176
jhilgert00 Avatar answered Oct 04 '22 21:10

jhilgert00