SourceKitService high memory usage

Two years ago, I found that ommitting self (for instance variable access, func calls within scope, etc.) would lead to a higher strain on SourceKitService. So, even though not required, I decided to explicitly use self everywhere.


Once Swift 3 and Xcode 8 were available, I started to move my projects to Swift 3. At first, I kept the explict usages of self. At that time, I didn't notice any issues with SourceKitService. Syntax highlighting worked extremely well and memory usage of SourceKitService hovered around 5 GB or less.


This past week, I took a second pass at my projects and removed all usages of self that were not necessary. I believe I'm now seeing slight slowdowns in syntax highlighting. And, about three times now, I've had to quit Xcode to reclaim memory used by SourceKitService. I have 32 GB of RAM and one day that process was using 31 GB (most of physical plus around 9 GB virtual). Other times, it tended to climb up to 15+ GB.


Has anyone else noticed high usage of RAM by SourceKitService and what may cause it? Anyone out there still doing explicit calls to self as I was? I'm trying to find patterns to what is going on. Thank you.


I have a snapshot of my projects with the explicit self, so will switch back to that for a while and monitor memory usage.

Replies

It's true.


It's use 30GB+ memory when I use Xcode 8 beta 3 with Swift. I noticed that syntax highlight would crash before huge memory use happened. Sometimes I have to close Xcode due to huge memory usage cause the disk to be filled. 😮

Yes, this service eats up more and more memory very fast.

Better force quit him instead of Xcode. Service then will be restarted automatically.

Because of this, beta 3 is almost unusable.

Wow, indeed beta 3 is unusable. Some very small edits to projects and SourceKitService hit 42 GB! (I only have 32 GB physical). This has happened three times now and is killing productivity.


Filed bug rdar://27455405


Going to now revert to beta 2. Thankfully, I didn't experience any source incompatiblities in my projects between beta 2 and 3, so will be an easy change.

I am having the same issue with Beta 3 although I am still able to get work done by restarting XCode 8 Beta 3 a few times a day. SourceKitService uses 33+ GB on my 32 GB machine.


@rsharp: Thanks for filing a radar bug on this

No problem, David.


Too early to tell, but so far so good with Beta 4. Will update the bug report after another day or two of testing.

SourceKitService uses 100% of CPU! Due єtogo MacBook running at the limit! Operating system works terribly slows!

macOS Sierra 10.12 (16A323) Xcode Version 8.0 (8A218a) Swift 3

I'm having the same problem with the production version of Xcode 8.0. Obviously SourceKitService has some sort of memory leak. I would expect this to be a priority fix from Apple, surely they wouldn't approve my software for distribution if it displayed the same problem. A kill -HUP to the runaway process brought the system back to a usable state.

Xcode 8.1 same problem.SourceKitServices use 6.95gb memory .... (out of 8gb) .

I am in the same boat, guys and the problem persists on XCode 8.1. I have to constantly go and kill SourceKitService as it's killing system performance on a regular basis:

  • Eats up GBs of memory
  • Consumes an impossible 180+% of CPU
  • Causes syntax highlighting in XCode to fail for minutes at a time

And basically, makes my computer act like it's the mid-2009 model I was so happy to replace not long ago!


Has anyone been filing Radar for this?

Same here on Xcode 8.2 GM. Pegs CPU around 100%. RAM usage currenty varying (as I watch) between 1.3GB and 1.4GB.


Swift project. Indexing is not (showing) as running.

It happens to me also but not with all the proyects, so i guess it happends when swift tryes to tell you that something is wrong

It's a nightmare ... I literally can not develop ... I'm waiting for Apple to fix this issues for year and a half. Xcode is extremely unstable, slow and whoever is using it should have a lot of patience in order to write code. Deleting DerivedData temporary fixes some of the issues ... but that's all.


Once again I'm begging Apple to fix these issues.


I. Nikolov

Having same problem.


To Repro.


Just create a Fresh CocoaApp Objective-C, then in applicationDidFinishLaunching start writing some code and run app a few times.


In NO TIME I hit 10GB with the SourceKitServices and the MBP is forced to its knees with fans spinning more wildly than when editing 4k Video in Final Cut Pro. And that says it all...


In every Guide I have read Apple is Spoon Feeding me with HOW important Memory Mangement is. How important a nice user experience is. etc etc.


XCode 8.2.1 Shipping Version is as nightmarish as XCode 8.0.


Great features but quite erratic Application

Today I am having problems with SourceKit also. It crashed my mac and I was able to reproduce the crash 3 times. I can not share the source code but for me it is happening at a different time than the original poster.


For me this occurs when I make a protocol equatable and then write a test that uses ==. It happens without compiling and without running tests. It is instantaneous as soon as I finish the last character on the line with ==


I am using Swift 3 on Xcode 8.2 in a very small project (in fact it's just the architecture with libraries etc, one app controller for navigation and one placeholder view controller).

Today is 2017-03-29 just updated my mac Sierra and xcode to 8.3

and com.apple.dt.SourceKitService still occasionally hit cpu maybe 200% 300% 400% who knows with very loud noise from fan.


i am working on pure c++ project and i persuaded all my fellow workers to switch to mac instead of windows

but now i am thinking to abandon this **** xcode and switch to VS of course reinstall this mac with windows.

Poor me why i decided to choose this mac and xcode