When you export 80 photos, the tempting Swift Concurrency move is to throw every photo into a TaskGroup and let the system sort it out. It reads cleanly. It also tends to decode too many full-size images at once, and on an iPhone that is how a batch that was fine at ten photos starts getting jetsam'd at eighty.
I build BatchMark , an iPhone app for finishing photos in batches, so this is a problem I have to take seriously. What follows is a teaching version of a simple pattern: keep a TaskGroup , but only let a small number of photos be in flight at a time. It is not the app's source.
The problem isn't the group. It's the queue length.
withTaskGroup is a good tool. It gives you structured concurrency, cancellation that actually reaches the children, and a place to collect results.β¦