Heavy memory usage of the Language Server
See original GitHub issueThis 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.jsonaltogether 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
.jsfiles in the__sapper__folder? (note that copypasting the same file in__sapper__/dev/clientdidn’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.jsonaffect 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:
- Created 3 years ago
- Comments:39 (20 by maintainers)
Top Related StackOverflow Question
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.
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.jsand comment out thesnapshotManager.getFileNames():Line 69:
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 😃