[Bug]: Memory leak?
Is there an existing issue for this?
- [X] I have searched the existing issues
OS/Web Information
- Web Browser: Chrome
- Local OS: macOS, ChromeOS
- Remote OS: Ubuntu 20.04, 22.04
- Remote Architecture: x86-64
code-server --version: 4.2.0, 4.3.0
Hi,
The memory consumed by the code-server (node) process gradually increases over time, regardless of whether and how the IDE is used. I have tested it multiple times and it has eventually used up all the 8GiB RAM of the server machine in a matter of 2 or so weeks.
Is this a well-known problem? Can I solve it permanently instead of rebooting the sever each time?
Many thanks
Steps to Reproduce
- Install code-server and run its daemon
- Continually measure memory usage of the process
- Wait :)
Expected
The memory usage should not be monotonically increasing
Actual
It is
Logs
No response
Screenshot/Video
No response
Does this issue happen in VS Code?
- [X] I cannot reproduce this in VS Code.
Are you accessing code-server over HTTPS?
- [X] I am using HTTPS.
Notes
No response
I can confirm that the memory consumed by the code-server (node) process gradually increases over time.
Does this also happen with native VS Code?
Side note: this would be a fun problem to solve. I'm not sure how, but I'm sure there are tools we could use to figure it out.
Does this also happen with native VS Code?
No. I have VSCode continually open on a MacBook for weeks and never had a memory issue. Same for a ChromeOS device.
I have the same / similiar problem on debian 11 with code server 4.4.0. Couldn't find the reason yet. When the memory is full, all sessions start to slow down, freeze and finally crash (Probably the memory leaking component / extension shuts down). Is there a way to pinpoint down this issue (Enable debug log as example)? I also thought to temporarily increase the Cloud Memory from 4GB to 8GB.
I also thought to temporarily increase the Cloud Memory from 4GB to 8GB.
My "solution" was adding a line to crontab to restart code-server every 24 hours 😆
Side note: this would be a fun problem to solve. I'm not sure how, but I'm sure there are tools we could use to figure it out.
https://www.npmjs.com/package/heapdump?
Today the system used 3.4GB of 4GB. I killed the extension volar and it droped by 3GB. Once i also read about memory problems with the extension settings sync. Is there a way to limit the ram usage of installed extensions?
Is there a way to limit the ram usage of installed extensions?
Not that I'm aware of. Found some things I'd read to look into it though:
- https://medium.com/@krtirtho/make-visual-studio-code-less-ram-consuming-faster-90db8c76a187
- https://stackoverflow.com/questions/53822808/visual-studio-code-took-10-7-gb-ram-usage-after-using-it-for-one-hour
- https://www.paulhyunchong.com/posts/vscode-high-memory-usage
- https://stackoverflow.com/questions/53658769/why-does-vs-code-require-so-much-memory-how-can-i-make-it-run-more-memory-effic
@jsjoeio Thanks, i will look into it!
I had issues with memory increasing, as multiple code-server instances would be open at once. Here is the issue: https://github.com/coder/code-server/issues/4351
It got solved by upgrading to a new version of code-server. Not sure if this is related but thought it was worth sharing.
I had issues with memory increasing, as multiple code-server instances would be open at once. Here is the issue: #4351
It got solved by upgrading to a new version of code-server. Not sure if this is related but thought it was worth sharing.
Thanks for sharing. I'm already on 4.4.0
Have you tried messing with the extensions? That also produced a solution for me :))
On Fri, 3 Jun 2022, 10:02 Alireza Ghasemi, @.***> wrote:
I had issues with memory increasing, as multiple code-server instances would be open at once. Here is the issue: #4351 https://github.com/coder/code-server/issues/4351
It got solved by upgrading to a new version of code-server. Not sure if this is related but thought it was worth sharing.
Thanks for sharing. I'm already on 4.4.0
— Reply to this email directly, view it on GitHub https://github.com/coder/code-server/issues/5201#issuecomment-1145755581, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALCTWHSLGC5JZI2GGA7LM2TVNHC3LANCNFSM5V2ST4SQ . You are receiving this because you commented.Message ID: @.***>
I have the same problem on CentOS 8.4 with code-server 4.4.0. It is not determined which version introduced this problem,as far as I can tell,there is no problem with 3.12.0.
Have you tried messing with the extensions? That also produced a solution for me :))
I'd rather wait for an official fix. But which extension? :D
Have you tried messing with the extensions? That also produced a solution for me :))
I'd rather wait for an official fix. But which extension? :D
Volar Extension used about 700MB per instance in my case. It also felt like it did still run in the background after closing an workspace.
I opened a large repo with many sub packages, and Memory Usage can be used almost 8G. When I just opened a sub package, Memory just 2G. So, code server will put every thing in workspace into memory?
I do not believe it puts everything in memory. Also it should be restricted by Node's maximum memory limit, I think? Which by default is pretty low. Have you confirmed it is code-server using that memory? It could be a language server or something.
Oh, sorry. I just found that the memory usage inside docker container and outside is not same, and the difference can be large. In container, use free -h get used + cached can be 7GB, but outside container, use docker stats containerID, show 1GB / 7GB.
i'm having the same issue, i only have the following extensions installed: "docker", "dotenv", and "yaml". I just put a memory limitation in my docker container config and set up a cron job to restart the container every day.