Skip to main content
On this page

iOS Performance Profiling on Windows: CPU, Memory, Dropped Frames

Profile without Instruments. kxdevice records CPU, memory allocations, network, energy, dropped frames and call stacks straight from your iPhone, from the command line or a web UI.

Last updated

For iOS performance profiling on Windows, kxdevice records data straight from an iPhone connected over USB: CPU usage, memory allocations with backtraces, dropped frames, network requests, energy and call stacks each have a command. Install a Release build, get the app's PID, then pick the recorder that fits your problem. If you'd rather not memorize commands, run kxdevice web and watch the graphs in a browser. The commands are the same on Linux and macOS.

What do I need before profiling an iOS app?

1. Install a Release build

Debug builds aren't optimized and carry assertions and debug info, so what you measure won't match what your users see.

> kxbuild build .\MyApp.xcodeproj -c Release --install

2. Launch the app and get its PID

Most sampling commands filter by process ID. Launching with kxdevice prints the PID. If the app is already running, find it with ps.

> kxdevice apps launch com.example.myapp
> kxdevice apps ps

3. Pick a sampler

The table below maps each kind of problem to a command. energy takes a single reading. The other commands sample until you press Ctrl-C. Add -n to limit the number of samples, and --udid when several iPhones are connected.


Which kxdevice command matches each Instruments template?

ProblemInstruments templateCommand
High CPU, battery drainActivity Monitorinstruments sysmon -i 1
Hot functions, where it stallsTime Profilerinstruments stackshot
Growing memory, suspected leaksAllocations / Leaksinstruments allocations --pid <pid> --backtrace
Dropped frames when scrolling, choppy animationCore Animation / Animation Hitchesinstruments fluidity --pid <pid>
Slow requests, heavy trafficNetworkinstruments netmon / instruments har --pid <pid> -o a.har
Energy useEnergy Loginstruments energy <pid>
os_log / signpost markersos_signpost / Logginginstruments activitytrace --pid <pid>
System calls, thread schedulingSystem Traceinstruments coreprofile
Poor network, high temperatureCondition inducerinstruments condition list, then enable …

Prefix every command with kxdevice. For example, to record one process's memory allocations with backtraces

> kxdevice instruments allocations --pid 1234 --backtrace -n 20

How do I track down stutters, memory growth and slow networks?

Janky list scrolling

Watch for dropped frames with fluidity while you reproduce the scroll, then use stackshot to see which function the main thread is stuck in during those frames. Release builds strip symbols by default. If stackshot shows only addresses, build with -D STRIP_INSTALLED_PRODUCT=NO.

Memory keeps growing

Record for a while with allocations --backtrace while you enter and leave the same screen a few times. Look for allocations that only ever grow and which class their backtraces point to. Watch the overall memory trend in the memory graph of the web interface below.

Slow loading on a poor network

Run condition enable SlowNetworkCondition SlowNetwork3GGood to simulate 3G on the iPhone, then capture requests with har. See which endpoint is slowest, whether requests wait on each other, and whether any are duplicated. Open the exported .har in your browser's developer tools. Run condition disable when you're done.

Get crash logs

Pull crash reports straight from a test device.

> kxdevice crash pull .\crashes

Can I do iOS performance profiling in a web interface?

If you'd rather not remember commands, start the local web interface. It has CPU and memory graphs, the process list, network monitor, crash reports and system log. Open http://localhost:8780 in your browser.

> kxdevice web

Use the web interface to spot the overall trend, then dig into the suspicious stretch with the commands in the table above. For every subcommand and option used in iOS performance profiling on Windows, see the kxdevice command reference.

Next steps