Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Instruments in Xcode, testing for leaks

I just started using Instruments, a nice little tool for testing memory allocations/ leaks and all that great stuff. But I'm pretty confused at how it works... Ive looked for tutorials explaining how to work with it, but no tutorials explained what to do with it.

I'll try to explain this: I have it set up to whenever I run my Xcode app, Instruments tracks everything. But the stuff that instruments record makes no sense to me.

There was one leak discovered, and after that it started leaking bytes. It says the leaked object is _NSCFString and some other stuff like that. Here is a screenshot

enter image description here

My question is, how do I interpret this? If there is a tutorial out there that explain this, please leave as an answer, or explain it to me.

like image 492
Gabriel Avatar asked Nov 23 '11 20:11

Gabriel


People also ask

How do I check for leaks in Xcode?

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 use memory leak instruments in Xcode?

From the toolbar of XCode, choose Product > Profile > Leaks to start a new instrument profile for tracking memory leaks.

How do I use instruments in Xcode?

Instrumenting AllocationsPress Command-I in Xcode, select Allocations from the list and press Choose. After a moment, you'll see the Allocations instrument. It should look familiar because it looks a lot like Time Profiler. Click the record button in the top-left corner to run the app.

How detect memory leak iOS app?

Xcode's Memory Graph Debugger If you haven't used this yet, it's easy to access while developing. Tapping on the icon will pause your application and generate a graph of the objects with their references to other objects. If there's leaked memory detected, you will see purple icons on the left pane of Xcode.


1 Answers

The best way to learn how to use Instruments is to watch the iOS/macOS Development Essential/Advanced/Foundation videos as well as the WWDC session videos on the topic.

You can find a list at past WWDC Session Videos to watch. They do not require a developer account to access.

iPhone Foundation Development Videos:

  • Session 916 - Getting Started with Instruments

WWDC 2009:

  • Session 414 - iPhone Performance Optimization with Instruments

WWDC 2010:

  • Session 304 - What's New in Instruments
  • Session 306 - Automating User Interface Testing with Instruments
  • Session 309 - Advanced Performance Analysis with Instruments
  • Session 311 - Advanced Memory Analysis with Instruments

WWDC 2011:

  • Session 310 - What's New In Instruments
  • Session 312 - iOS Performance and Power Optimization with Instruments

WWDC 2012:

  • Session 409 - Learning Instruments

WWDC 2014:

  • Session 418 - Improving Your App with Instruments

WWDC 2015:

  • Session 412 - Profiling in Depth

WWDC 2016:

  • Session 411 - System Trace in Depth
  • Session 418 - Using Time Profiler in Instruments

WWDC 2018:

  • Session 405 - Measuring Performance Using Logging
  • Session 407 - Practical Approaches to Great App Performance
  • Session 410 - Creating Custom Instruments

WWDC 2019:

  • Session 411 - Getting Started with Instruments
  • Session 414 - Developing a Great Profiling Experience
  • Session 421 - Modeling in Custom Instruments

2020 Tech Talks:

  • Demystify and eliminate hitches in the render phase
  • Find and fix hitches in the commit phase
like image 181
Andrew Avatar answered Oct 21 '22 06:10

Andrew