Instruments

RSS for tag

Instruments is a performance-analysis and testing tool for iOS, iPadOS, watchOS, tvOS, and macOS apps.

Instruments Documentation

Posts under Instruments subtopic

Post

Replies

Boosts

Views

Activity

Memory leak in SwiftUI when pressing keys (detected by instruments)
I've discovered what appears to be a system-level memory leak when pressing any key in Swift UI projects. This issue occurs even in a completely empty SwiftUI project with no custom code or event handlers. When monitoring with Instruments' Leaks tool, I observe multiple memory leaks each time any key is pressed. These leaks consist primarily of: NSExtraData objects (240 bytes each) NSMenuItem objects (112 bytes each) Other AppKit and Foundation objects Has anyone else encountered this issue? How can I fix this behavior? While the leaks are small (about 5-6KB per keypress), they could potentially accumulate in applications where keyboard input is frequent.
1
0
26
6d
Processor Trace not Working on C/C++ Console Apps
Hi, When I run the new Processor Trace instrument on a simple C or C++ console app, it hangs in "Analyzing - Transferring data" upon finishing the measurement. When I run it without any other instrument, I get the error: Failed to stop recording session: Data Providers emitted errors: CPUTrace Any ideas what I could try, or how to get a more verbose log of this failure? Best, Ronny P.S.: I'm using a Macbook Pro M4 Pro 14". MacOs Version 15.4 Beta (24E5228e)
2
0
238
1w
Understanding power usage on a macOS app
It looks like, for some reason, our apps are using a bunch of power sometimes. sysdiagnose has this in the power log: Never mind. Including the output of sysdiagnose has "sensitive language," and it won't tell me what is sensitive, making this a waste of my time. ETA: Ok, I I can attach the file: power.log I've gone through the energy documentation, but it seems geared towards embedded, not macOS, so I'm not sure how I can figure this out more. The extra problem, of course, is that we have a network extension, two daemons, and a GUI app. šŸ˜„
0
0
226
2w
Instrument Recording Failure - CPU counter failed
Hi, Iā€™m encountering an issue while using xctrace & instruments to profile an application on macOS. Specifically, when trying to record a trace using the CPU Profiler template, I get the following errors: Failed to start the recording: configureHardwareCounters: Failed set kpc configuration: Operation not permitted. Unexpected failure: Couriers have returned unexpectedly. macOS Version: 15.3.1 Chip: Apple M4 Pro Xcode Version: Xcode 16.2
2
2
327
3w
Instruments has an error and a typo
* [Error] Failed to stop recording session: Failed stoping ktrace session. (xcode-select version 2409) So why can't it stop the ktrace session? And how long has that typo been around? šŸ˜„ (Look, I've kept typos in log messages for years because it differentiated that message from other messages.)
1
0
209
3w
Configuring "high frequency sampling"
Hey folks, We are looking for a way to increase the sampling frequency beyong what's currently called "high frequency sampling" for CPU profiler (or time profiler -- doesn't really matter for us). We are aware that this is not offered through the UI but wondering if we can somehow experimentally enable this via the .tracetemplate (plist). Basically, we see that samplingRate exists (in the plist) but don't see it having an effect on the actual runs. The resulting trace file always lists sample-rate-micro-seconds="1000" for the data table. E.g., <table trigger="time" pmc-events="Cycles" target-pid="SINGLE" schema="counters-profile" needs-kernel-callstack="0" sample-rate-micro-seconds="1000"/> Cheers
0
0
221
4w
XCTestCase Async Setup Function Always Causes Leak in Instruments
I'm developing a library and using XCTest for unit tests. While trying to profile the test suite, I noticed that Instruments seems to report a leak every single time the async throwing setup function is called, no matter what. For example, This will report a leak: final class LeakTests: XCTestCase { override func setUp() async throws { try await super.setUp() } func testLeak() async throws { try await Task.sleep(nanoseconds: 5_000_000_000) } } This will not report a leak: final class LeakTests: XCTestCase { // override func setUp() async throws { // try await super.setUp() // } func testLeak() async throws { try await Task.sleep(nanoseconds: 5_000_000_000) } } Any ideas on why this might be happening, or should I just file a bug report? It makes it quite difficult to use the leak detection for unit tests, as it shows hundreds of leaks when the whole suite is ran.
2
0
389
Jan ā€™25
Instruments showing incorrect values
Hello, Iā€™m encountering an issue with the Instruments app while running a benchmark on an M2 Ultra Mac Studio. Despite being certain that GPU activities involving memory read and write operations are occurring, all related performance counters consistently return 0. Interestingly, this problem does not occur when using the same code on an M1 MacBook Air, where the counters behave as expected. What could be causing this discrepancy? Any insights or suggestions would be greatly appreciated. Thank you!
0
0
344
Jan ā€™25
How to let instruments - app launch template wait for process to launch , rather than actively launch by instruments
Hi there, How to let instruments - app launch template wait for process to launch , rather than actively launch by instruments? I need to profile the app launch performance when clicking a push notification or cold launch via a url link. How to let instruments to wait for the process and collect the data? Currently, I tried the command xctrace record --template "App Launch" --attach MyApp --device-name 'Phone-Dev' --output mytrace.trace But it soon failed with 'Cannot find process matching name: MyApp'. How to make it work?
0
0
419
Jan ā€™25
Change recording mode when using xctrace
Hey, In the UI of the Instruments app, I can change the recording mode to immediate. Is that possible when using xctrace? It seems to use deferred as a default. I've tried to create a template, set the recording mode to immediate, and use that template for recording. However, that doesn't seem to work. At least the exported TOC of the .trace will have the following summary: <summary> <start-date>2025-01-11T13:00:11.365+01:00</start-date> <end-date>2025-01-11T13:00:30.525+01:00</end-date> <duration>19.160279</duration> <end-reason>Target app exited</end-reason> <instruments-version>16.0 (16A242d)</instruments-version> <template-name>core_animation_fps</template-name> <recording-mode>Deferred</recording-mode> <time-limit>12 hours</time-limit> </summary> This issue might be related to: https://developer.apple.com/forums/thread/735948 Thanks a lot!
3
0
466
Jan ā€™25
How to symbolicate kernel callstacks (or what is kernel.release.t6020)?
Hi everyone, (I am running on an M2 MacBook Pro 14 inch with 96 GB of memory) I've been profiling with Instruments to find out why program suddenly goes from full CPU usage (all of my threads active and all cores working) to about 33% CPU usage. An Instruments system trace is showing me a massive performance cliff where I suddenly get taken off the performance cores and only run on efficiency cores. The performance cores are then occupied by "kernel.release.t6020". What is this thing? I have kernel callstacks enabled but I only get the instruction pointer and have no symbols for any of those callstacks. I'm accustomed to Windows development where kernel symbols are available so you can see deeply into the kernel to know why you're spending time there (for example, semaphore wait or thread scheduling). Is there a way for me to get a similar level of information or kernel symbols so I can see what the kernel is doing? Around the time I observe the performance cliff, I also noticed in the narrative view some of the preemptions are done "because thread was balanced off CPU i (P Core) to optimize the system's CPU performance". What does this mean? Have I begun to hit some sort of thermal limit? Here are some example screenshots of what I am seeing in Instruments:
2
0
475
Jan ā€™25
PacketLogger doesn't capture logs for iOS devices.
I'm unable to capture Bluetooth logs via PacketLogger from my iPhone 11 (iOS 18.2) and iPad Pro (iPadOS 17.5.1) with Mac mini M2 macOS 15.2 (24C101). I've installed Bluetooth profile on both devices, restarted multiple times connected to the computer, it shows device as online, however PacketLogger captures nothing at all. For test I've installed profile on macOS and PacketLogger captures everything as it should. I saw some posts here from earlier this year, that people were having similar problems with PacketLogger. Please suggest a solution or confirm that it is a known bug.
3
0
832
Dec ā€™24
How to collect macOS traces on customer machines with symbols for OS libs?
Our customers are large enterprises and we need to be able to collect traces on our customers' endpoints in support cases. Especially critical are performance problems. So far we've instructed our customers to use ktrace: sudo ktrace artrace -p appname --type=profile We would then open this trace in Instruments with the CPU profile and load our own symbols. The problem is, that symbols for system libraries are missing. In one instance we see that all of the high load is coming from a syscall made by libpcap. But all symbols other than our own are missing. How can we collect traces which include those symbols? I tried to use ktrace symbolicate in tests where I recorded a trace and then used ktrace symbolicate to collect system lib symbols, but it fails for most libraries, including libpcap and the syscalls. This is somewhat surprising, because dyld_info -exports /usr/lib/libpcap.A.dylib is able to print the symbols including offsets. So what is the recommended workflow for this scenario? Installing Xcode is of course not an option on a customer machine, especially not in an enterprise scenario.
2
1
533
Dec ā€™24
Identifying memory leaks
I'm having an issue with my swiftui macOS application where it is continually consuming more memory over time and after a couple of hours will grind to a halt. I've watched a few videos now on how to use Xcode Memory Graph and Instruments to identify the source of a leak (I assume it is a leak). These videos all provide very obvious issues as examples but mine seems more elusive and I don't know how to identify which part of my code is the cause of the issue. After running instruments I see the following but the leaked objects are not always consistent: Xcode Memory Graph shows NSSet as the culprit which is shown under CoreFoundation (not my App). I really am a beginner here and because it's not showing me somewhere in my app that I can go and investigate I'm really stuck.
4
0
1.3k
Dec ā€™24
Not seeing signposts when profiling a unit test (Xcode 16.1)
While I was recently profiling some code from a Swift library, I noticed that XCTest added in signposts for the measurement tests, which I found really helpful to "home in" on the code I wanted to profile digging around in the stack trace. I tried to add my own signposts to provide just a bit of my own markers in there, but while it compiles and profiles equivalently, the signposts just aren't showing up. This is with Xcode 16.1, macOS Sequoia (15.1) and a swift library, using XCTest and profiling within one of the unit tests. Is there something in this sequence that doesn't allow the library to set up signposts and have instruments collect them? The flow I'm using: import os let subsystem = "MyLibrary" class MyClass { let logger: Logger = .init(subsystem: subsystem, category: "fastloop") let signposter: OSSignposter init() { signposter = OSSignposter(logger: logger) } func goFast() { let signpostId = signposter.makeSignpostID() let state = signposter.beginInterval("tick", id: signpostId) // ... do a bunch of work here - all synchronous signposter.endInterval("tick", state) } } Is there something I'm doing incorrectly in using this API, or not enabling to allow those signposts to be collected by the profiler? I do see the signposts that XCTests injects into the system, just not any of the ones I'm creating.
1
0
668
Nov ā€™24
Cannot run Animation Hitches Instrument
I'm trying to run the Instrument "Animation Hitches", but it fails immediately after starting on the iPhone. This happens on multiple projects, including a brand new project. I get the following errors: Timestamp | Message (Before Run Started) | Unexpected failure: Couriers have returned unexpectedly. (Before Run Started) | Failed to start the recording: Failed starting ktrace session. The issue also happens with the instruments App Launch, but not with any other that I tested. Is this a bug? Using Xcode Version 16.1, Mac Mini M1 Sequoia 15.1. Running project on iPhone 14 Pro iOS 18.1.
2
1
878
Nov ā€™24