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

  • 50gb?

  • After 1 minute of testing I saw the process list 42gb

  • I encountered the same thing🥲

Replies

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

  • I'm not sure how this is related. Can you explain?

  • I think I understand how it's related now.. SwiftUI is probably breaking Xcode

  • I’m torn between laughing and crying

Add a Comment

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....

Post not yet marked as solved Up vote reply of motw Down vote reply of motw
  • Yes what a pain. I have a new MacBook Pro sat in it's box! I'm just glad this little m1 MacBook Air is a *****.

  • This saved me from a definite headache. I was almost upgrading macOS. Thanks for updating.

  • But if someone already updated to Monterey it's still can be run from terminal like: /Applications/xcode_12/Xcode.app/Contents/MacOS/Xcode

Add a Comment

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.

  • Thank you for this! I'm running Monterey 12.0.1 and 13.1 and this is a workaround for me too.

    I just purchased this 16in M1 Max with 64GB of ram and it is rendered completely useless by this bug.

    Only fix was running Xcode in Rosetta.

  • I just tested this (13.2 beta, monterey) and it didn't work for me. swift-frontend still chews up all available memory.

Add a Comment

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.

  • Unfortunately Rosetta mode makes no difference for me

Add a Comment

I have also been having this issue on a 2018 Intel MacBook Pro, on Xcode 13.1. Tried to downgrade to Xcode 12, but I am running Monterey :(( This is a really debilitating bug, that I hope gets more attention.

  • Don’t know the downsides of this approach but there’s a workaround to run Xcode 13 on Monterey https://www.youtube.com/watch?v=qv_yvHuBgXA

Add a Comment

So aside from this forum post and having a month old feedback assistant request (with no response) does anyone have any experience how to get Apples attention on this?

I have a case going with Apple, reported through the Feedback app. I've sent them a project that confirms the bug, a video showing the memory growth when using Xcode 13.1, and a link to this forum thread.

In my case, the memory running wild happens if the Canvas fails to load/build a preview. If I rebuild the project (Commad+B) after the canvas fails to load, the swift-frontend processes are killed.

I have stopped using the Canvas for now, and instead use Command+R to preview changes in the simulator, until Apple fix the issue.

Spotlight indexing hasn't stopped on my M1 machine for almost a month and a half, it's using something like 70% of two or three cores, continuously. Originally I thought it was the 11.6 update that did it but now I'm pretty sure it's this bug. I reported it in FB9639588 and linked back here. Still no movement on the bug.

  • That sounds more like this bug, which has a workaround detailed in this thread: https://developer.apple.com/forums/thread/683277

    (Someone recently commented saying the workaround stopped functioning, but that’s not true in my experience. Seems to still do the job on 13.1 / 13.2 beta)

  • Oh holy crap you're right—I have also had this "Xcode eats all the memory" bug, but it seems the fix detailed in that link has given me my processors back. Thanks!

Add a Comment

This issue appears to be fixed for me in 13.2 beta 2 (13C5066c). I did a full clean build (and nuked derived data) and the issue is gone!

  • My test project still rockets up to 60gb in no time on 13.2 beta 2 (13C5066c) after clean and nuking derived data. Just got an out of memory panic on my 64gb MacBook Pro.

  • sounds promising. giving that a shot.

  • Beta 1 you mean, released October 27?

Add a Comment

Just a workaround until something permanent. Two things: (1) don't use automatic preview - if you can make due with the Simulator, and (2) keep the activity monitor up so when swift-frontend shows its ugly head you can quit it... don't force quit, and don't quit xcode. Good luck. 

This thread is my new hang out spot when I can't get any work done

I'm having the same issue. To the point where I can't even continue working anymore. When I try to run, my memory start to build up until in need to shut these processes down.

Can someone respond to this draft if a fix is found?