Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Memory leak? #5201

Open
3 tasks done
aghasemi opened this issue May 13, 2022 · 19 comments
Open
3 tasks done

[Bug]: Memory leak? #5201

aghasemi opened this issue May 13, 2022 · 19 comments
Labels
needs-investigation This issue needs to be further investigated
Milestone

Comments

@aghasemi
Copy link

aghasemi commented May 13, 2022

Is there an existing issue for this?

  • 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

  1. Install code-server and run its daemon
  2. Continually measure memory usage of the process
  3. 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?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

No response

@aghasemi aghasemi added bug Something isn't working triage This issue needs to be triaged by a maintainer labels May 13, 2022
@benz0li
Copy link
Contributor

benz0li commented May 13, 2022

I can confirm that the memory consumed by the code-server (node) process gradually increases over time.

@jsjoeio
Copy link
Contributor

jsjoeio commented May 13, 2022

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.

@jsjoeio jsjoeio added waiting-for-info Waiting for more information from submitter and removed bug Something isn't working triage This issue needs to be triaged by a maintainer labels May 13, 2022
@aghasemi
Copy link
Author

aghasemi commented May 14, 2022

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.

@jsjoeio jsjoeio added needs-investigation This issue needs to be further investigated and removed waiting-for-info Waiting for more information from submitter labels May 19, 2022
@jsjoeio jsjoeio added this to the Backlog milestone May 19, 2022
@LaCocoRoco
Copy link

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.

@aghasemi
Copy link
Author

aghasemi commented May 23, 2022

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 😆

@benz0li
Copy link
Contributor

benz0li commented May 24, 2022

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?

@LaCocoRoco
Copy link

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?

@jsjoeio
Copy link
Contributor

jsjoeio commented May 25, 2022

@LaCocoRoco
Copy link

LaCocoRoco commented May 25, 2022

@jsjoeio Thanks, i will look into it!

@Sharpz7
Copy link

Sharpz7 commented Jun 1, 2022

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.

@aghasemi
Copy link
Author

aghasemi commented Jun 3, 2022

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

@Sharpz7
Copy link

Sharpz7 commented Jun 3, 2022 via email

@leeyzero
Copy link

leeyzero commented Jun 5, 2022

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.

@aghasemi
Copy link
Author

aghasemi commented Jun 5, 2022

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

@LaCocoRoco
Copy link

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.

@Tzxhy
Copy link

Tzxhy commented Jul 19, 2023

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?

@code-asher
Copy link
Member

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.

@Tzxhy
Copy link

Tzxhy commented Jul 20, 2023

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.

@DarkPhyber-hg
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation This issue needs to be further investigated
Projects
None yet
Development

No branches or pull requests

9 participants