memory leaks found but no stack trace is shown - ios

I started looking for the memory leaks when I received memory warning.I have read some material on how to solve memory leaks but when I run Instruments things shown seem a bit abnormal to me. The call tree is empty and the extended detail panel is showing no stack trace. Also I am not able to understand the graph shown in Root Leaks(cycles & roots) I have attached the screenshots below.
screenshot: cycles & roots
Leaks

Ray Wenderlich and his team explain this sort of thing very nicely.
https://www.raywenderlich.com/2696/instruments-tutorial-for-ios-how-to-debug-memory-leaks
Time for more studying. :o)

Related

Unbounded Memory Growth IOS App (CFString) - How to debug?

I have an IOS app that displays images and text in a UITableView. When I scroll up and down I get this unbounded memory growth. I have used Allocations to attempt to find out where this memory growth comes from. Please see below. From what I can see, CFString takes up a huge amount of memory. It doesn't appear to be from my code(based on StackTrace of CFString) as seen in Figure 2.
Please can someone advise? I'm really stuck. My app is crashing after a few minutes of scrolling after exceeding around 2GB of memory. I would appreciate any general pointers on how to debug the origins of the memory issue. The CFString stack trace appears all grayed out and I'm not sure how to proceed to diagnose the issue.
Figure 1
I am looking at CFString and the persistent memory is huge.
Figure 2
Clicking on CFString:
Try using the Instruments app, in the Xcode utilities folder. Specifically you want the Leaks instrument. It will find leaked memory, and then help you figure out where that memory gets allocated.
Run your app for a while, then break it and examine your heap.
(It's rather complex and tricky to use. Much more than I can explain in an SO answer. I suggest digging up a WWDC video or other tutorial on using it.)
There is also a simple memory graph tool in Xcode that flags leaked blocks, but it doesn't give you as much information. (It's one of the little icons in the debug bar above the debug console. The icon is 3 little circles with lines between them.)

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.
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?
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.
You can see the stack trice in right side of the screen. And after that to scroll to the class and method that create the leak. Sometimes is hard to understand why you have the leak.
Take look on my image
I have TermsViewController and I have NSMuttableAttributed string which creates memory leaks. Also if I select the row with TermsViewController.setupInfoText() it opens the code.
If you want to find the code allocating the leaked memory, switch to the call tree view using the jump bar. To find your code in the call tree view, invert the call tree view and hide the system libraries.
Double-clicking one of your functions in the call tree view will let you drill down to the line of code that allocated the leaked memory.
Read the following article for more detailed information on using Instruments to find memory leaks:
Measuring Your App's Memory Usage with Instruments

increasing memory allocation on iOS application

I've developed an iOS application. There is a main screen which is displaying a google map and there are many markers, polygons etc in it.
At the beginning app was using around 120MB of memory.
- I touched settings button of my app and went to the settings page. there is no code. only segue connection in the storyboard (red line on the image)
- then I came back to the map screen (white line on the image)
You can see the memory allocation. every time when I open the map screen memory usage is increasing
What is the problem. What should I do?
The graph you have captured in Xcode is a decent overview of your memory consumption, but I'm afraid you are going to have to use more specific tools to diagnose this leak: Instruments comes shipped with Xcode and will help you track memory leaks; you will have to research (at least) the Leaks and Allocations instruments to figure out why your View Controller isn't being released.
While it is impossible to diagnose without seeing your code, that graph heavily suggests that your map view controller is not being released (hence the steady growth each time you create a new one)
To hazard a guess, I'd imagine you are creating a new mapView in viewDidAppear rather than viewDidLoad

How to detect the reason of memory leaks according to the address providing by Leaks?

I have found a memory leaks through Leaks, but it only showed the address and the leaking bytes as below. I want to know how to detect the reason causing the memory leaks? Anybody know?
Open the extended detail panel (on the right).
Select one of the elements in the list and look at the extended detail panel, which shows the stack trace that caused the object to be created, as below:
Double click on it to see the code for that method.
For more about How to Use Instruments in Xcode, read the raywenderlich excellent tutorial here

Xcode 4 Memory Leak Instrument how to get line of code where leak occurred

I'm attempting to use the Memory Leak instrument in Xcode 4 with iOS 5.1 (ARC enabled) and I am spotting memory leaks, but how the hell do I get to the line of code causing the leak? I've read a few tutorials on this but it seems to be an older version of the instrumentation tool because when I click on the extended detail tab and double click on items in the backtrace I'm presented only with useless assembly code. Also none of the items on the stacktrace are any of the classes that I've written. Am I missing something?
If your code leaks memory, you will see your relevant methods in the details tab, right where you are looking. They are displayed in black as opposed to methods in the APIs which are gray. You can't look into API Methods of course, hence the assembly code. If there is really something wrong in your code, set the slider on the bottom of the tab on the rightmost position and you should see the concerned methods.
If still none of them are in your code, you probably just don't leak anything. (There are actually not many scenarios in which ARC-Code can leak memory. Retain cycles are probably the most common one) I stumbles over one or two cases in which an API was 'leaking' memory. There is really nothing you can do about it and most likely, it's just a false positive anyway rather than a real leak. If you are only 'leaking' a few bytes, I wouldn't worry about it.

Resources