Heavy memory usage of the Language Server

See original GitHub issue

This is some sort of documentation of my experience with Svelte Language Server (SLS) that I think needs attention.

In my moderately large Svelte project I decided to try using the Svelte Atom extension (VS Code has proven to be the same in regards to this issue, which makes sense – it’s not the editor’s fault). After a few moments of coding I’ve noticed severe performance drops and system freezes. Turns out that the SLS process was using up to 2 GB of RAM. After pulling the project apart I’ve discovered that the files that are causing such heavy memory consumption are /jsconfig.json and /__sapper__/*. It’s worth noting that at the time I had both the development and the production builds compiled, so the __sapper__ folder was twice the size.

jsconfig.json had a particularly interesting field:

{
  "exclude": ["node_modules", "dist"]
}

Turns out that SLS was honoring this field somehow, in that:

  • removing jsconfig.json altogether brought the memory consumption to acceptable (~350 MB)
  • keeping it in this way was giving the ridiculous 2 GB of memory usage
  • adding "__sapper__" into the array of excludes also brought the memory consumption to acceptable (same as when removing)

My thoughts on this:

  • why is SLS affected by a bunch of .js files in the __sapper__ folder? (note that copypasting the same file in __sapper__/dev/client didn’t increase the memory consumption, so it’s not simply linearly increasing with respect to the amount of files)
  • is all this consumed memory really necessary?
  • how exactly does jsconfig.json affect SLS?
  • perhaps it should be somehow made clearer how to tweak memory consumption if it gets out of control, possibly by documenting the usage of jsconfig.json

I don’t really know what to make of this issue, hoping for some sort of discussion and possibly documentation improvement, but feel free to close this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:39 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Jun 23, 2020

We added additional measures to prevent initial file bloat. If anyone still experiences high memory usage, please report in here. Else I will close this in a few weeks.

1reaction
illrightcommented, Jun 4, 2020

A terrible workaround for until this issue is fixed: locate your Svelte extension directory, open node_modules/svelte-language-server/dist/src/plugins/typescript/service.js and comment out the snapshotManager.getFileNames():

Line 69:

// before:
return Array.from(new Set(__spreadArrays(files, snapshotManager.getFileNames(), svelteTsxFiles)));

// after:
return Array.from(new Set(__spreadArrays(files/*, snapshotManager.getFileNames() */, svelteTsxFiles)));

You lose some IntelliSense, but retain syntax highlighting and at least the performance doesn’t drop randomly. And if you’re anything like me, that should be good enough to get by 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Way too many recommendations and high memory usage in ...
The memory usage is the language server. Hover over variables with it enabled and you'll see usage spike tens of MB. You can...
Read more >
Why does each VS Code instance/window needs its own ...
And why does it use so much RAM? Each VS Code window uses ~500 MB of RAM just for terraform-ls.exe.
Read more >
Update the Java Virtual Machine Memory Allocation
Allocating more memory to the language server can prevent problems caused by large documents. You can configure two types of memory allocation limits....
Read more >
On VSCode-remote, why is python jedi language server ...
There are run-jedi-language-server.py scripts running with high RAM usage. The vscode-remote server is running on a single repository.
Read more >
Performance degradation due to high CPU and Memory ...
High CPU and Memory usage is observed on the database server of EngageOne Deliver, impacting the overall performance. CPU utilization was not reduced...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found