swift-frontend memory usage

I think I've found a memory leak with GeometryReader. The memory footprint of swift-frontend grows 50gb> with this single line

I have detailed the issue here: https://github.com/Func-Main/swiftui-memory-bug

Is anyone able to confirm? I don't think this is an issue related to the purely to the .aspectRatio modifier, but rather GeometryReader in general.

This image was after 30 seconds

I've tried  Xcode 13.1 RC and I confirm this bug is still present. Only option for me to reliably develop SwiftUI at the moment is to use Xcode 12. I tried the latest Xcode 13 Beta before GM and this issue was present.

This bug also makes the entire system unresponsive, as it thrashes to disk/swap. My SSD will read/write at 900+ MB/s.

This bug will put a ton of wear and tear on our SSDs...

Clearly Xcode devs missed this, since they were working on their pre-release 64GB M1 max machines...

Xcode 13.2 beta (13C5066c) still has this issue!

I've installed the latest official release (13.1) to fix this issue that I faced on all my development units - the update took many hours (all night and longer) on my iMac 24'' M1 2021 (similar on MacBook Air M1 2020) and... the issue is still there... No response from Apple/Xcode development team - that's so disappointing. Such a massive and obvious show stopper should have grabbed more attention from them, but they just release new betas on and on without any solution nor at least "we are working on it" or similar response here.

Hey! I experienced a similar problem too. The swift-frontend and SourceKitService processes were overloading memory incrementally. I managed to find what caused this error. But I do not understand the true reasons for this problem. For fun, I tested build with different values. In my case, the memory overload occurred due to the fact that after Text () there was .padding (with value) followed by .foregroundColor (with RGB). For clarity, I made a screenshot from Xcode:

Take a look. Maybe someone is also getting an error because of this, and you can get through this problem. Although for me it is a mystery why this is happening.

I can confirm the issue I originally posted is still present in Xcode 13.2

I have found related topic. Check this out. https://developer.apple.com/forums/thread/652691

Still happening with Xcode 13.1 official release :(

The other thread doesn't seem to be related, but wondering if there's something in the Xcode build settings that can be disabled until Apple fixes this debilitating issue?

Same problem. And Monterey not support xCode 12. Nice....

Ha, although I don't think a 64gb max will save you from this. I have exactly that machine sat in it's box because of this bug. I need Xcode 12 and can't use Monterey yet 😢

Seems like SwiftUI is tripping up Xcode 13 a lot. Commenting out a random ScrollView or other view sometimes works. swift-frontend process has gone so high to 145GB at one point and I only have 32GB RAM on this machine (Big Sur 11.6.1 / Xcode 13.1).

For what it's worth, running Xcode 13.2 beta in Rosetta mode made this stop happening for me (despite it happening when not running in Rosetta mode).

It was fun getting an "out of application memory" popup like ten minutes into using this 64GB machine, though.

Xcode 13.1 was unusable and crashed my machine repeatedly throughout the day yesterday. Downgrading to 12.5.1 as suggested by @motw enabled me to get back to work. Thank you for sharing this workaround!

Should you need Xcode 13, ymmv but I'm not seeing any memory consumption issues on Xcode 13.0 (13A233), from an M1 Max MBP running Monterey 12.0.1 (21A559).

I'm also getting this problem in Xcode 13 on both Big Sur on an Intel MBP, and on Monterey on an M1Pro MBP. Running Xcode in Rosetta mode also fixed it for me so far.

swift-frontend memory usage
 
 
Q