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

Apparent memory leak #565

Open
ScottG489 opened this issue Jan 12, 2023 · 63 comments
Open

Apparent memory leak #565

ScottG489 opened this issue Jan 12, 2023 · 63 comments

Comments

@ScottG489
Copy link

Problem/Motivation

This addon increases in memory consumption until my system runs out.

Screen Shot 2023-01-11 at 5 50 17 PM

I've been monitoring it since my last incident and I had to restart the host. The host has a total of 4GB of memory which meets the documented requirements.

Though I've only been tracking memory per-addon for the duration of the first graph, I have been running this addon for over a year and I've only been having memory usage issues recently:

Screen Shot 2023-01-11 at 6 38 43 PM

I usually update addons pretty quickly after there's a release, and I can see v5.4.1 was released right around that time. Though from the release notes nothing sticks out.

I'm on the latest version and default config.

Expected behavior

For the memory usage of this addon to not increase indefinitely.

Actual behavior

Memory appears to increase indefinitely. Last time my system used up all memory and swap and locked up due to swap disk usage and I had to restart.

Steps to reproduce

As far as I can tell I'm using VS Code normally. I've only installed one extension (vim).

Unfortunately, I don't have any more information than above, but I'm happy to troubleshoot and get more information if you have suggestions on how to do so. I connected to the container and it doesn't have ps or even free so it seems like my tooling in the container is limited.

Thoughts on what this could be?

@leowinterde
Copy link

Same problem here.

1 similar comment
@limitless00net
Copy link

Same problem here.

@github-actions
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Feb 16, 2023
@JonathanVarild
Copy link

Just updated my Home Assistant addons and started experiencing issues with my home "lagging". After investigating the issue, I noticed that the Visual Studio addon consumed 95% CPU and 57% ram. Turning the addon off lowered the overall resource usage on my Home Assistant system. See attached pictures.
Skärmavbild 2023-02-20 kl  19 29 49
Skärmavbild 2023-02-20 kl  19 29 25

@ScottG489
Copy link
Author

ScottG489 commented Feb 20, 2023

Still an issue.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Feb 21, 2023
@doug-hoffman
Copy link

I've also seen a memory leak...

image

image

I noticed that it started happening after I opened folder /, because I was going back and forth between editing a local addon and HA config. After switching back to /config and restarting vscode, I haven't seen the problem again.

@BNolet
Copy link

BNolet commented Mar 5, 2023

I specifically started configuring the Terminal & SSH addon to be able to use VSCode Remote - SSH specifically because of this memory issue.

My theory is that with each loading of the VSCode web interface, it's spinning up a new process without killing the old one. I say this because judging by the memory footprint over time, I can see stark stepwise jumps of memory use.

@ScottG489
Copy link
Author

@BNolet I've seen similar spike patterns as well and had also theorized that. I wonder if something changed recently with how new instances are being spun up.

I'm also considering using an external client, though I'll be using intellij instead. I've already got it working via sshfs.

@VNRARA
Copy link

VNRARA commented Mar 19, 2023

Have any of you guys been experiencing random reboots because of this maybe? My HA install has been rebooting pretty frequently and couldn't find a culprit. I've started disabling add-ons and after I noticed (see #589 as well) VSS uses port 1337 which shows up a lot in the logs.

@ScottG489
Copy link
Author

@VNRARA I've had to manually reboot my system because I ran out of memory, and soon after swap. Once everything starts swapping to disk the system essentially locks up.

I'd suggest enabling resource usage sensors for your add-ons. I've found it very valuable since I've done so. You can do this by going to the services created for each add-on and enabling the CPU and memory percent sensors.

@VNRARA
Copy link

VNRARA commented Mar 20, 2023

I think both Node-Red and VSCode might be culprits here. (I'm on a 4GB system)

image

VS code is already using: +100mb RAM from boot and Node-Red +115MB.

image
image

This also sometimes happens:

image

[02:28:34] [172.30.32.2][c05a3361][ManagementConnection] Unknown reconnection token (never seen).
[02:28:34] [172.30.32.2][e68f3661][ExtensionHostConnection] Unknown reconnection token (never seen).
[02:34:01] [172.30.32.2][e9f8b661][ManagementConnection] New connection established.
[02:34:03] [172.30.32.2][aa78680f][ExtensionHostConnection] New connection established.
[02:34:03] [172.30.32.2][aa78680f][ExtensionHostConnection] <468> Launched Extension Host Process.

@ScottG489
Copy link
Author

I think a few hundred MB for either of those is more than acceptable.

Bringing this discussion back on topic though, I'd pay attention to sustained increases to the memory usage of VS Code as an indicator that you're also seeing a memory leak.

@Xlinx64
Copy link

Xlinx64 commented Mar 20, 2023

I have the same issue on my home assistant blue, after I disabled VSCode and didn’t use it anymore I didn’t have any reboots. When I used it heavily it crashed every half an hour.

@VNRARA
Copy link

VNRARA commented Mar 20, 2023

Mine did crash so it may also be node-red

@ScottG489
Copy link
Author

@Xlinx64 Wow that's pretty bad if it happens so quickly. I'd double check the system requirements in the docs for this add-on to make sure your system meets them.

Also, here's an automation I created as a fallback to restart the add-on if it uses up too much memory. Be sure to change the value based on your system's resources:

trigger:
  - platform: numeric_state
    entity_id: sensor.studio_code_server_memory_percent
    above: 20
action:
  - service: hassio.addon_restart
    data:
      addon: a0d7b954_vscode

@Xlinx64
Copy link

Xlinx64 commented Mar 20, 2023

@ScottG489 Thank you for the script!
But I dont dare to use the add-on until it is fixed. I use the File Editor add-on for now.
I have to admit that on the day with the crashes I opened and closed it a lot since I did some template sensors.

@BNolet
Copy link

BNolet commented Mar 20, 2023

You can also use VSCode Remote - SSH with the SSH & Terminal add-on if you're looking for a longer term solution: https://community.home-assistant.io/t/vs-code-remote/129887/24?u=brandonnolet

@boojew
Copy link

boojew commented Mar 28, 2023

Yea, I have the same issue on 16gb machine.. Takes about 1-2 weeks before I run out of memory :( Could be related to coder/code-server#5201, but that is super vague.

@github-actions
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Apr 28, 2023
@ScottG489
Copy link
Author

Still an issue.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Apr 29, 2023
@MiddleSiggy
Copy link

I am having the same issue, I posted some more information in this ticket:
coder/code-server#6213

@rbalaev
Copy link

rbalaev commented Jun 9, 2023

the same problem, until the complete loss of memory

@le-clu
Copy link

le-clu commented Jun 14, 2023

Same issue here.
I keep VSCode off, and only switch it one when needed. Today I forgot to switch it off again and had to hard-reboot my Pi.

image

@ScottG489
Copy link
Author

If you'd like to help manage this for now, you can create an automation to restart the VSCode add-on if it uses up too much memory. Something like this (adjust the above number for your situation):

trigger:
  - platform: numeric_state
    entity_id: sensor.studio_code_server_memory_percent
    above: 20
action:
  - service: hassio.addon_restart
    data:
      addon: a0d7b954_vscode

Note that you'll need to enable the memory entity for this add-on in the supervisor integration.

@github-actions
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Jul 15, 2023
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Mar 12, 2024
@holdestmade
Copy link

Still an issue for me

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Mar 13, 2024
@fribse
Copy link

fribse commented Mar 14, 2024

Still an issue here as well!

@Maddjik
Copy link

Maddjik commented Mar 17, 2024

I am also having this problem in the last couple of weeks ! Cannot use vscode more than a couple minutes before it starts to misbehave and hang Haos. I dont know if this is related but node red wont start too and i had to delete it and reinstall. Running in a vm with 6gb ram and 2 cores x 2 threads (i9 9th gen)

@Noirbonn666
Copy link

Ok, so I think I figured out the cause, not sure if it is the addon or the specific extension that is causing it though.

First let me start off, I'm a Linux noob, I started maybe 6 months ago for my aquarium automation build, so if I say something dumb, please bare with me lol,

What I found out by using the 'top' command was 'node' was using a lot of CPU. Also, if I would leave the VSC instance, and go back, it would add another 'node' process. I tested this 3 times to verify, and each time it added another 'node' and would stack the CPU and Mem usage.

VS Issue

I used 'ps -Flww -p' with the PID at the end and it would show me a folder path to the .js file. I'm guessing this is the file that is being ran with node. Part of the path had the authors name, which allowed me to look at all the plugins that were enabled.

VS Issue 2

I looked through all the enabled extensions in VSC and came across...

VS Issue 3

Once I disabled and restarted VSC the issues when away. The CPU usage would go back to 0% for the Addon once I left the VSC screen. I reenabled this plugin again, restarted VSC and problem started again. So, disabled and now it works without issue, except the color formatting is gone and all the other features like autocomplete of entities. I also noticed that in extension marketplace it shows the version as 1.39, where as on the extensions GitHub it shows 1.40 being released last month. Granted nothing in the changelog that would hint the issue would be fixed though.

Again, I'm Linux dumb, so forgive me, but I'm guessing that means the Node command that is left running when you leave/disconnect from the VSC instance is not being shutdown and is running as a zombie. Hopefully there is a fix for this soon. I like VSC so much better than File Editor as I need all the help I can get with syntax errors.

Definity solved the RAM and CPU Issue ...

@Noirbonn666
Copy link

It may be more related to this issue here:
keesschollaart81/vscode-home-assistant#2656

Copy link

github-actions bot commented May 5, 2024

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label May 5, 2024
@ScottG489
Copy link
Author

Still an issue.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label May 6, 2024
Copy link

github-actions bot commented Jun 5, 2024

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Jun 5, 2024
@ScottG489
Copy link
Author

Still an issue.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Jun 7, 2024
Copy link

github-actions bot commented Jul 8, 2024

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Jul 8, 2024
@Maddjik
Copy link

Maddjik commented Jul 8, 2024 via email

@mniewiera
Copy link

sadly the same for me. have to restart the addon everytime i use it.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Jul 9, 2024
Copy link

github-actions bot commented Aug 8, 2024

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Aug 8, 2024
@ScottG489
Copy link
Author

Still an issue.

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Aug 13, 2024
@xamboozi
Copy link

xamboozi commented Sep 2, 2024

I'm experiencing this as well

@sinclairpaul
Copy link
Member

As it's an IDE, I'm confused by all the comments as to why you can't just stop the addon when not in use. I don't believe that the source application is designed to perpetually run.

@Maddjik
Copy link

Maddjik commented Sep 3, 2024

As it's an IDE, I'm confused by all the comments as to why you can't just stop the addon when not in use. I don't believe that the source application is designed to perpetually run.

The resource hogging happens in the first few minutes I launch the program. After 5-10 minutes, if I don't stop it my HAOS VM becomes unstable and I gotta force restart it via the hypervisor. It is literally not usable.

@Ftown14
Copy link

Ftown14 commented Sep 3, 2024

That is the problem, and you have to. It doesn't change the fact that there is a memory leak. That is why it is submitted as an issue.

@sinclairpaul
Copy link
Member

The resource hogging happens in the first few minutes I launch the program. After 5-10 minutes, if I don't stop it my HAOS VM becomes unstable and I gotta force restart it via the hypervisor. It is literally not usable.

Then it isn't the same issue as originally logged (which was an increase in memory usage over time). I would suggest looking at how you have the app configured (i.e. which folders it is running fil watchers for), and also resources on your system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests