Profiling Xamarin.iOS Applications with Instruments
In this article, we’ll describe how to use Instruments on any iOS device and any Xamarin.iOS application. We’ll also look at how to profile applications in the simulator.
We can use the iOS developer app to profile Instruments in Xamarin.iOS or we can use the simulator. Mono uses its Just-in-Time model to compile code and Instruments doesn’t interpret this kind of data well, so it can be difficult to work with output from simulator-based applications that use Instruments. Because of this issue, we’ll concentrate on how to use the developer app to interpret Instruments output in this document.
You will need to switch over to your Mac to use Instruments on your Xamarin.iOS for Visual Studio project.
Opening the Instruments App
Select your device and run the Instruments app
- Open your project.
- Select the
- In the main menu, select
Run -> Upload to Device. The application will now be built and uploaded to your device.
- Open a terminal window and execute:
Instruments will now open, and you’ll see the following:
iOS/Memory is selected on the left, and
Allocations on the right, as in the screenshot. You can choose
other profilers (
I/O Activity, etc), but the
following screenshots are all from the
Choose button, and you’ll be presented with this
Now we need to choose the right target on which to execute:
If you don't see your device listed under the
menu, check the
Console for error messages, and ensure you have set
up your device for development through the Xcode Organizer
Window->Organizer menu in Xcode):
Record to start profiling.
The following screenshot shows an example of profiling using Instruments.
In this brief topic, we’ve described how to configure an environment, select your iOS device, and how to use the iOS Instruments developer app to profile a Xamarin.iOS application.