24

I use Xcode on my mac, which has 8GB ram. When I open Xcode and don`t open any project and wait about 2 minutes, Xcode eats all the memory in ram, (4GB, 5GB...)

Can anybody tell me why and how to fix this?

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
user1651186
  • 241
  • 1
  • 2
  • 4

6 Answers6

12

I have been investigating this issue for some time too. I think one solution (which I need to credit the user justin for) is to set several config values for Xcode. It should be done after quiting the Xcode of course.

In the terminal execute the following commands:

defaults write com.apple.dt.XCode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4

defaults write com.apple.dt.XCode IDEIndexDisable 1

this will prevent indexing and reduce the number of compile tasks. This allowed my Xcode to leave me some RAM for actually doing some work.

to delete these settings, eg indexing:

defaults delete com.apple.dt.XCode IDEIndexDisable

As mentioned, this was discussed in this question.

In addition, cleaning the Xcode cache allowed to reduce the speed that the RAM was eaten with. (at ~/Library/Developer/Xcode/DerivedData - it is at your home dir, and also it is probably hidden, so easier to access with Terminal).

Edit/Update:

Apparently, this helps with the memory issue (although still need to restart Xcode regularly). However you are loosing some nice-to-haves: instant error checking, control-drag-and-drop IBOutlet adding to the controller header (need to do it the old way - type in and then connect), probably some other helpful features that come with indexing. So be aware.

Community
  • 1
  • 1
Ole
  • 121
  • 1
  • 4
2

found a temporary solution here

Run that command every once in a while and it helps with my 8GB

Irina
  • 409
  • 5
  • 17
  • I have tried purge command, but it had no impact to my memory configuration. That was on OS X 10.8 – vedrano May 13 '13 at 16:54
2

I'm surprised I haven't read the real answer/problem here although there is no solution. I see you mentioned you don't even have to open a project but generally the problem occurs when using storyboards. I've confirmed this, sent examples to Apple, filed bug reports, waited for new releases, nothing yet. Somewhere down the line there is a leak when editing storyboard views. If you are editing raw code you will never see the ram usage increase but the second you begin editing a storyboard with multiple views and segues the problem arises. I currently run 24GB of ram and it can be consumed in less than an hour when editing views in a storyboard. Like others have mentioned, the only solution is to restart Xcode. Simply closing the project is not good enough.

Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
1

I faced the same problem, but in correlation to Interface Builder and Storyboard access.

After some thinking, it becomes clear that after Storyboard file in my project enlarged to some amount (currently about 1.5MB on disk), XCode and IB have problem.

While changing text in some (e.g. IBLabel) object, it needs about 0.5 seconds for each letter, what gives 3 seconds for a change of 6 character word. That slows me a lot.

XCode restart helps and releases all occupied memory...until next working session.

I have strong impression that IB makes undo buffer after each change (e.g. change single letter) because after each single change, memory footprint enlarges for about 20 MB (probably Storyboard size in RAM, on disk is 1.5 MB).

And after XCode restart, undo buffer has gone, and some memory has accordingly released.

I would like to know a way to limit undo buffer size, and test it with that smaller size.

Configuration is: Mac Mini, 4 GB RAM, OS X 10.8.3, XCode 4.6, XCode 4.6.1, XCode 4.6.2

I am currently back to XCode 4.5 and situation seems a little bit better but problem is still here. I suppose this version has less features than 4.6 and according that difference it uses less memory.

Ok, seems like XCode 4.5 actually CAN release some of memory that Interface Builder allocates.

Update on May 21. 2013: I upgraded from 4GB to Mac Mini 2011 8GB RAM and did not notice problem yet.

vedrano
  • 2,961
  • 1
  • 28
  • 25
0

There's no real way around that problem.

It's discussed on many websites. The only solution that helped me with this problem is, restarting XCode now an then. I don't think that there will be a real solution for this problem.

mas-designs
  • 7,498
  • 1
  • 31
  • 56
  • 1
    I successfully uninstall my xcode, and download it again from apple – user1651186 Sep 06 '12 at 07:45
  • I successfully uninstall my xcode, and download it again from apple but nothing happens – user1651186 Sep 06 '12 at 07:46
  • Yeah, uninstalling and downloading it again will not help you. There is NO way around that problem. Just restart it now and then, and you will be fine. – mas-designs Sep 06 '12 at 07:47
  • if NO any way to fix this problem, must have format and again install mac os in my MacBookPro :( – user1651186 Sep 06 '12 at 07:56
  • 2
    No you take the MacBook Pro and dumb it into the garbage you. Also reainstalling Mac Os will NOT solve this. THIS is a KNOWN (everybody knows it) issue and EVERYBODY ( like every person which uses xcode) has to deal with it. Restart the program new once in a while and you will be fine. – mas-designs Sep 06 '12 at 07:59
  • Ahhhh... restart the program not help me, because Xcode eat all memory from ram during 2 minutes – user1651186 Sep 06 '12 at 08:02
  • Closing other applications and widgets might help you to, just try everything to keep the memory foot print down. (I run XCode with 3 GB of memory, and everything is pretty smooth, btw) – rien333 Oct 07 '12 at 13:16
0

XCode is a real memory monster, and if you trying using one of the "instruments" it eats even more. Depending on the tasks some people do not have that many issues, specially if they have more memory.

Personally I started with 2GB and XCode was just... painful

After upgrading to 8GB I just had to restart every now and then

I have heard that people with 16GB do not complain that much, and just have to restart XCode once or two a day.

It looks quite strange to me that you use all your memory after 2 minutes. I might guess that there is some setting of yours that is making all XCode leaks much worst. Have you tried deleting all your ~/Library/Developer folder and setting files?

SystematicFrank
  • 16,555
  • 7
  • 56
  • 102