4

I am testing a mobile application on iPad at the moment.

The problem is:

I noticed that the longer that I ran this application, the slower it got and eventually it would crash.

I suspect there is a memory leak somewhere in the code.

My question is

How do I demonstrate there is a memory leak for this iOS mobile application?

I have tried:

General --> Usage, but it does not show how much RAM it is using.

3

1 Answer 1

2

As per the developer documentation on Apple's website:

The following scenarios are common causes of leaks, you can confirm whether your observations are actually memory leak??

  • Retain has been called on an object without a corresponding release call when the object is no longer referenced.
  • An object has been allocated and initialized with APIs that don’t cause the object to autorelease.
  • If a leak isn’t an object, you may be calling an API that assumes ownership of a malloc-created memory block, and you are missing a corresponding call to free().

To investigate a leaked object using a backtrace:

  1. Click the Leaks instrument in the timeline pane to display leak-related information in the detail pane.
  2. Choose Leaks from the detail type list in the navigation bar of the detail pane.
  3. A list of leaked objects by backtrace is displayed.
  4. The Leaks by Backtrace view aggregates all of the leaked blocks by their allocation point, because a single mistake in source code can result in multiple runtime leaks as the code is executed repeatedly.
  5. Select an object you want to investigate. Click the focus arrow next to the object’s memory address to display the memory history of the object in the detail pane, along with corresponding reference counts and method calls.
  6. Press Command-3 to display a stack trace for the selected object in the extended detail area of the inspector.
  7. Click the Collapse button in the extended detail area to hide system calls in the stack trace. This makes it easier to locate your app’s methods.
  8. Double-click a method in the stack trace to display its code in Instruments.
  9. Click the Xcode button at the top of the detail pane to open the code in Xcode for review and editing.

To investigate a leak using the call tree:

  1. Click the Leaks instrument in the timeline pane to display leak-related information in the detail pane. Select Call Tree from the detail type list in the navigation bar of the detail pane.
  2. A list of method calls related to any detected leaks is displayed. Press Command-2 to show the display settings area in the inspector pane. Under the Call Tree display settings, select Invert Call Tree and Hide System Libraries.
  3. The most recent method calls are shown first. It also helps narrow down the list of method calls to ones made by your app. Method calls made by your app are colored black and preceded by a user code icon.
  4. Select a method call you want to investigate.
  5. Press Command-3 to display a stack trace for the selected method call in the extended detail area of the inspector. Double-click the method call in the stack trace to display its code in Instruments.
  6. Click the Xcode button at the top of the detail pane to open the code in Xcode for review and editing.

You can fine more details here

Other Solution:

1
  • 1
    When copying content from another site and pasting the exact same thing as it is here, the least you can do is add a link to the web page containing original content. and also may be start by saying "As per 'xyz':" OR better yet add the link itself in a comment on the question! Copying others' content without proper credit is considered plagiarism developer.apple.com/library/ios/documentation/DeveloperTools/… Commented Aug 10, 2016 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.