Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

XCode swallowing all memory

Lately, XCode's use of memory has resulted in freezing my machine. This tends to occure during compilation, but not only. No such problems from command line or alternative IDE CodebBlocks with same compiler. Any suggestion for troubleshooting?


Developer Information:

Version: 3.2 (10M2309)
Location: /Developer
Applications:
Xcode: 3.2.4 (1708)
Interface Builder: 3.2.4 (804)
Instruments: 2.7 (3014)
Dashcode: 3.0.2 (333)
SDKs:
Mac OS X:
10.5: (9L31a)
10.6: (10M2309)


Activity Monitor for XCode:

Real 2.51GB
Virtual 15GB
Shared 49MB
Private 2.79GB
Virual Private 4.74

MacBook5,1, Mac OS X (10.6.1)

Posted on Mar 3, 2011 1:19 PM

Reply
Question marked as Best reply

Posted on Mar 4, 2011 9:28 AM

Hi frangipane

Given the problems you're having with Xcode not tabbing properly and now this freezing issue, I'm wondering if your Xcode installation is damaged in some way. There's absolutely no way that Xcode should be causing freezes.

If I were in your position, I would clear out all cache files, then delete Xcode preference files, then run the developer tools de-install script. I would then re-install Xcode and hope this fixes the problem. You probably don't need to download a new version from Apple's web site provided you get no problems when you mount the dmg file.

It's going to take a couple of hours, and when you've done it you may be no better off!

Good luck (you might need it)

Bob
27 replies

Nov 21, 2011 1:12 PM in response to abqowen

Same here, using XCode 4.2.


I have a late 2011 iMac and recently upgraded from 4GB RAM to 16GB to stop the annoying swapping that starts after some hours of use.


After reboot, about 3GB is used, only using XCode and Safari. Using only those programs, 10GB is used after one day of use and contually increasing. I then exit XCode and then only about 3GB is used again.


Note also that the memory usage reported by the Activity Monitor for XCode is low even if all memory is used up by XCode.


Apple, what about using Instruments on XCode to find your own memory leaks?

Dec 7, 2011 9:01 AM in response to frangipane

I have only encounted this issue when editing .xib files with Inteface Builder, Since Xcode 4.0 I simply just try to draw everything programmatically instead of using IB, and never running out of memory again unless I have to modify my old projects they still have some .xib file.


The 4.2 new feature storyboard has the same problem probably due to it uses IB as well, or it would be really a time saver for me.

Mar 1, 2012 4:12 AM in response to MotaSay

There's definitely something to this. I'm pretty new to development, and I recently messed up #include directives which didn't have proper header guards. There was a series of "#include nested too deeply" errors at the top of a list of over 1000 compiler error messages. The debugger console was also running the in bg and I had forgotten about it (though it wasn't doing anything other than waiting for input). I noticed something was amiss when the fan started going nuts and Xcode's memory usage was up around 2GB (I have 4GB RAM in my MB Pro). Force Quit and Quit Process via Activity Monitor were responding so slowly that I had to use killall via the Terminal in order to actually get Xcode to shut down.


More to the point: every attempt to re-open the same project only resulted in the same problem. I fixed the #include directives outside of Xcode in a text editor and compiled with a Makefile. No issues there. Tried re-opening the project in Xcode but the problem happened again, and it was even showing the old compiler warnings for the new files. I suspect Xcode was loading the cache of all those compiler errors in spite of the changes to the files. So, I temporarily removed the offending files from the project directory and reopened the project. Naturally, Xcode didn't find those files and didn't try to load all the associated compiler warnings. With the project open, I moved the files back into their original directory. Xcode found them again, but the error messages were gone and memory usage was normal again.


Message was edited by: mdbraz changed 'warnings' to 'error messages' in last sentence

Jul 27, 2012 7:47 AM in response to frangipane

OK it's been while no one has said anything. You all solved it or gave up!?


MBPR with 16G, Mountain Lion, and Xcode 4.4. Same problem here with one project after an hour only 400 MB is left!!! And funny that I do nothing except watching Storyboard. I'm creating document now from project so all I am is in storyboard scrolling. No running, no debugging. and no nothing. Just watching.


It seems no matter how much you have memory it eats up all of it. And with 60 UIViewCntroller in the page is so slow and buggy to scroll around.


I hope I can find something after all.

Jul 27, 2012 7:57 AM in response to Maziyar

Mine finally quit doing it - I do not have an exact reason why it stopped, but one of the things I did was clear XCode's cache. It seemed to stop doing it around that time.


http://stackoverflow.com/questions/5714372/how-to-empty-caches-and-clean-all-tar gets-xcode-4


I have not seen this problem in probably 8 months now. Currently on a 21.5-inch, Mid 2011 iMac with 12GB running XCode 4.3.2. Building apps for both OSX and iOS.

Jul 28, 2012 12:24 AM in response to Maziyar

When I first posted on this, I had an older machine with 2 gigabytes of memory, which was fine for Xcode 3, but not Xcode 4. I now have an 8 GB machine. At first I still had a lot of problems, but with Xcode 4.3.2 the problem seemed to be much better for me. Xcode still uses a lot of memory, but doesn't gobble it all up in the same way that it used to. I am doing development for Mac OS, not iOS, and I haven't gone to Xcode 4.4 yet.

Feb 8, 2013 1:44 AM in response to frangipane

I suddenly got this problem with Xcode 4.6 nose-diving in seconds with a catatrophic memory leak causing me to despair. It seemed to be triggered after I have added an image to some forms. I noticed that I had inadvertently specified the same image (a .jpg) as being both the main image and the highlighted image on the view. Sometimes it was just enough to select the view to trigger meltdown. That seems to have stopped now.


Xcode still munches through memory from time to time but its controllable and you can predict and work around it. I am working on a 4GB machine which probably does not help.

Mar 17, 2013 2:26 AM in response to frangipane

I think I have the same problem, although mine is significantly more pronounced! I'm running a Mac mini 2012 with 8GB of ram and all the latest updates (as of yesterday).

Every time I click on a (any) view controller, or even worse try to edit the dimensions of anything within the view controller, my 8GB of memory collapses to about 6MB~ in under a minute. If I then stay with the view controller selected in about 5 minutes the swap used can be around 20GB.

This issue has basically rendered my interface builder useless, as I don't get the same memory leak when editing raw code.


Does anybody have any fix suggestions?

Apr 8, 2013 12:44 AM in response to frangipane

I have been investigating this issue for some time too. I think one solution (which I need to credit the stackoverflow 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).

XCode swallowing all memory

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.