|
A common problem people run into when they start profiling their apps with Instruments is finding the code that is causing problems. Many instruments initially show general statistics instead of statistics about the code you wrote. For example the Allocations instrument initially shows the number of memory allocations and amount of allocated memory for hundreds of memory categories. If your app allocates a lot of memory, you want to find the code that allocates high amounts of memory. How do you find the functions that allocate the most memory? Switch to the call tree view. Switching to the Call Tree ViewClick the jump bar menu and choose Call Trees to switch to the call tree view. If you don’t know where the jump bar is, look at the following image: The call tree view has a listing for each function that executed while Instruments profiled your app. Finding Your Code in the Call Tree ViewWhen you switch to the call tree view, it initially shows functions that you didn’t write. How do you find your code in the call tree view? Click the Call Tree button in the bottom bar to open a popover with a series of checkboxes. Select the Invert Call Tree and Hide System Libraries checkboxes. Inverting the call tree brings the interesting functions to the top. Hiding the system libraries hides Apple’s code, leaving your code in the call tree view. |
Subscribe and get exclusive articles on Swift development, a free guide on moving from tutorials to making your first app, notices of sales on books, and anything I decide to add in the future.
TextEditingReference collection I am the new maintainer of TextEditingReference, a collection of open-source libraries for working with text in iOS and Mac apps. The libraries in the collection include the following: Markdown editing views Rich text editing views Text views with syntax highlighting Syntax highlighting libraries TextKit utility packages If you develop apps that involve editing more than one line of text, you may find a library or two in the TextEditingReference collection to...
Swift Concurrency Learning Resources One of the biggest pain points experienced Swift developers have is dealing with Swift concurrency, especially the changes in Swift 6. Many developers are sticking with Swift 5 to avoid the pain of migrating their code to Swift 6. If you are having trouble learning about Swift concurrency, I put together a list of resources that should help. F**king Approachable Swift Concurrency F**king Approachable Swift Concurrency is a good starting point to learn...
Find the Code Causing Long SwiftUI Updates with Instruments Instruments comes with a SwiftUI instrument to find performance problems in your SwiftUI apps. This article shows how to use Instruments to find the code that causes long SwiftUI view updates. If you have never used Instruments, read the following article to learn how to profile your app with the SwiftUI instrument: Find the SwiftUI Views that Update the Most Using Instruments Finding Long Updates When you finish profiling your app,...