CIContext memoryTarget defaults and Extended Virtual Addressing on macOS

Is the memoryLimit option mentioned in WWDC26 session 305 the same option as CIContextOption.memoryTarget?

The session says the default memory target on iOS is 256 MB. What is the default memoryTarget on macOS?

Also, the session recommends the Extended Virtual Addressing entitlement for interactive RAW editing. That entitlement does not appear to be available for macOS, so does Core Image automatically use a larger intermediate cache budget on macOS?

Should memoryTarget be used only for export contexts, or can/should it also be tuned for interactive editing contexts with cacheIntermediates enabled?

Thanks!

Answered by Engineer in 893526022

If the memoryTarget is unspecified or default, the same memoryTarget will be used for apps built for both macOS and iOS. These limits determine how much CIContext will divide the task to ensure that a single render pass meets the specified target.

However, on macOS, a CICContext (with an unspecified memoryTarget) allows for increased allocations that scale with the total system RAM, enabling better interactive frame rates. This was not enabled on iOS due to concerns of jetsam.

CoreImage will assume a large virtual address space on macOS, a longstanding policy.

Thanks

Could you also respond to the memoryTarget questions?

Yes, the memoryLimit option referenced in the session is the same as CIContextOption.memoryTarget

Thanks.

What is the default memoryTarget on macOS?

Also, should memoryTarget be tuned for interactive editing contexts with cacheIntermediates enabled, or is it mainly intended for export/batch render contexts?

If the memoryTarget is unspecified or default, the same memoryTarget will be used for apps built for both macOS and iOS. These limits determine how much CIContext will divide the task to ensure that a single render pass meets the specified target.

However, on macOS, a CICContext (with an unspecified memoryTarget) allows for increased allocations that scale with the total system RAM, enabling better interactive frame rates. This was not enabled on iOS due to concerns of jetsam.

Default is 256MB for both macOS and iOS apps

Increasing the memoryTarget can improve both export time and interactive renders (particularly on iOS for the reasons mentioned above). The concern for large images or memory-intensive filters (ie ones with impactful ROI expansion) the default memoryTarget may result

  • Additional computation and due to overdraw of dividing the task into smaller regions
  • Stalls in the pipeline if (Metal) compute tasks are dispatched faster that the GPU can process (which is fairly common for complex CIImage graph)

Thanks, that helps.

For a macOS app interactively editing large RAW images, would you generally recommend leaving memoryTarget unspecified so Core Image can use its macOS scaling behavior, or explicitly setting a larger value when the app knows it is rendering large images / filters with significant ROI expansion?

Default values are reasonable for simple applications. However, I recommend using larger values in the cases you mentioned above to reduce the ROI expansion caused by tiling.

It’s important to use a value that’s large enough to avoid stalls due to overlapping render tasks. As a guide, I suggest using recommendedMaxWorkingSetSize (I expect a third of that would be more than sufficient).

https://developer.apple.com/documentation/metal/mtldevice/recommendedmaxworkingsetsize

CIContext memoryTarget defaults and Extended Virtual Addressing on macOS
 
 
Q