[sourcekit-lsp] Any way to reduce memory usage?

I've been trying to get a little Raspberry Pi-based workstation going, and one thing that I've noticed is that sourcekit-lsp consumes an enormous amount of memory, even for very small projects.

The project I'm working on now has 2174 lines of code (including tests), across 19 files. The total size is 208K. The device is an RPi 4 (4GB model), running Ubuntu 20.04 aarch64. Admittedly, 64-bit isn't ideal with only 4GB of RAM, but the only ARM toolchain I could find doesn't even include sourcekit-lsp for 32-bit releases (and it seems they may have stopped 32-bit releases altogether?).

Anyway, sourcekit-lsp appears to require 1.6GB to work on this project, which still seems excessive. That's more than Chromium and Codium (a version of VSCode with a port for the RPi) combined, each with 4 or 5 tabs open. And this is a very small project!

It's eating up half my memory and brings the entire system to a grinding halt, to the point where it's simply not usable.

Are there any features I could disable or flags I could set to reduce this? It would be really nice to get this device up and running reliably. It's a shame because - when it works - it actually works really well, and it's nice to have a little desktop machine you can edit and run Swift on.

What kind of memory usage are people seeing on other platforms? Is this maybe something unique to my configuration?

1 Like

On Linux, sourcekitd is in the same process as sourcekit-lsp, so usually the majority of memory would be for cached ASTs. 1.6GB seems pretty high for a small project though. I don’t know much about memory profiling on Linux, but it would be helpful to know how that memory breaks down.

Does the persistent memory grow as you edit or stay steady? Is it growing as you browse to new files?

1 Like