SolidSun
SolidSun

Reputation: 2189

Profile memory usage of iOS File Provider extension

We want to profile the memory usage of the File Provider extension of our iOS app using Instruments. A File Provider extension only has access to a limited amount of RAM (currently 15MB on iOS 17), thus optimizing memory usage is important because the system kills the extension process if it tries to allocate more memory.

So, how can we profile the memory usage of a File Provider extension?

Ideally, I would imagine something like this to be possible:

  1. Install optimized build to device via Xcode.
  2. Launch Instruments, select Allocations template and make Instruments wait for the extension to be launched.
  3. We open up the Files app on device and start browsing the extension contents.
  4. Extension process is launched and Instruments is attached to it to record allocations.

Is something like this possible? How can this be done?

Upvotes: 0

Views: 110

Answers (1)

SolidSun
SolidSun

Reputation: 2189

According to Apple's documentation I found that this is not possible on device with memory constrained apps because the system kills the process when reaches the memory limit. When you attach to the process with Instruments it also causes the memory usage to increase and the process is killed. You can however test this in the simulator where memory usage is not constrained.

The steps described in the question are possible but really only usable in the Simulator for the reasons mentioned above. Just install the optimized build and launch Instruments, select the Allocations template and the correct simulator and target process.

The target process for the File Provider extension in the Instruments dropdown is either the name of the executable if it is running, or an extension named similarly as the app itself if it is not running. Hovering over with the mouse, it displays the path in a tooltip, so you can check that to be sure you select the correct one.

Upvotes: 0

Related Questions