Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SourceKitService sucking memory and grinding all processes to a halt

I am having a lot of trouble with stupid SourceKitService. It is taking up like 20GB of memory sometimes and just means my lapTop is pretty much useless it is so slow. I am using xCode 6.4 and working in Swift. I am working on a large project so I am sure that contributes to the problem.

But I was just wondering if anyone has found away to tame the SourceKit beast and stop it from going out of control and taking all my memory?

like image 956
villy393 Avatar asked Jul 21 '15 09:07

villy393


1 Answers

I encountered this issue in XCode 7 and it was still present after upgrading to XCode 8. In my case I narrowed it down to a bit of code that calls a database wrapper (GRDB) like so:

db.execute(sqlStatement,arguments:["ParamNameA":someValueA,"ParamNameB":someValueB]);

If the number of elements in the arguments dictionary is more than 20, SourceKitService memory usage goes nuts (15 GB or more) and the compile times are over 10 minutes. If the number of elements is less than or equal to 20, memory usage of SourceKitService is under 200 MB and compile time is a couple of seconds.

I would suggest looking for bits of code that have a dictionary of more than 20 elements and commenting them out to see if the problem goes away.

like image 70
David Wood Avatar answered Oct 14 '22 02:10

David Wood