Recently, since XCode 11 when I use it, builds and indexes grab a lot of memory.

Activity monitor shows a process (it seems like it does so when indexing or building files) called swift and my Mac soon starts to lag. This process gathers a lot of memory (sometimes it gathers up to 70 GB) from my computer and I have to kill the process every time in order to get back to normal and start using my Mac as before.

enter image description here

enter image description here

How do I stop this memory pressure from increasing this much when compiling ?


1 Answer 1


To clean your build in Xcode (under Product menu) and deleting cache in ~/Library/Developer/Xcode/DerivedData/ (not the whole Developer folder, as it has simulators etc. too) was my original suggestion.

Finding on Stack Overflow got me these:

  • Restart your Mac.

  • After making a copy of your project in a safe place, right click on the project file and select "Show Package Contents". Delete the .xcworkspace file and rebuild your project. Use the backup file if it persists.

  • Bugs in Swift which can be triggered by

    • Declaring arrays in multiple lines
    • Programming errors.
    • Several concatenations in one line
    • ...it was caused by a 20 item array literal. Had to switch to different syntax.

and so on..

New ones:

Your best bet is to use search and sort feature on SO, see linked and suggested questions to find problems in your code. Might even want to use source control to move back to the part where it was not problematic. After you've exhausted your search and trials, edit the question, I'd put a bounty. If it is not helpful, ask mods to kindly migrate.

  • Hi! I did what you said here and I am still getting the same frustration: The swift process starts to run and occupy a lot of my memory. I could not find any issues in my code that may cause this. I read about the issues that I may find ( the links you provided ) but I was not able to 'reproduce' the issue that is causing my swift process to start. Maybe you can give me more details on how to trace the issues Dec 16, 2019 at 10:33
  • I am not aware of the issues in Swift or Xcode for that matter, unfortunately. You should revisit the questions, their "Linked" ones in the sidebar and then edit in the question what you've tried. I think this would not be very old to be migrated to SO. Also, see latest edit.
    – anki
    Dec 16, 2019 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .