Simple SwiftData app exhibits excessive & persistent memory growth as items are added

[Submitted as FB14860454, but posting here since I rarely get responses in Feedback Assistant]

In a simple SwiftData app that adds items to a list, memory usage drastically increases as items are added. After a few hundred items, the UI lags and becomes unusable.

In comparison, a similar app built with CoreData shows only a slight memory increase in the same scenario and does NOT lag, even past 1,000 items.

In the SwiftData version, as each batch is added, memory spikes the same amount…or even increases! In the CoreData version, the increase with each batch gets smaller and smaller, so the memory curve levels off.

My Question

Are there any ways to improve the performance of adding items in SwiftData, or is it just not ready for prime time?

Example Projects

Here are the test projects on GitHub if you want to check it out yourself:

I should have added…

  • Xcode version: 15.4 (15F31d)
  • iOS target: 17.5

Just wanted to close the loop on this…I ended up submitting a dev support ticket and was told that this issue was fixed in iOS 18 (beta at the time).

After testing on iOS 18, I confirmed that they did address the lag issue. The good news: the SwiftData version remains responsive, even with 3,200 items. The bad news: it still uses twice the memory as the CoreData version.

So I've decided to stay with CoreData in my app until there’s a compelling reason to switch back.

Simple SwiftData app exhibits excessive & persistent memory growth as items are added
 
 
Q