Skip to content

Apparent memory leak #565

Description

@ScottG489

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?

Activity

  1. leowinterde commented on Jan 14, 2023

    @leowinterde
  2. limitless00net commented on Jan 17, 2023

    @limitless00net
  3. github-actions commented on Feb 16, 2023

    @github-actions
  4. added
    staleThere has not been activity on this issue or PR for quite some time.
    on Feb 16, 2023
  5. JonathanVarild commented on Feb 20, 2023

    @JonathanVarild

    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

  6. ScottG489 commented on Feb 20, 2023

    @ScottG489
    Author
  7. removed
    staleThere has not been activity on this issue or PR for quite some time.
    on Feb 21, 2023
  8. doug-hoffman commented on Mar 5, 2023

    @doug-hoffman

    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.

  9. BNolet commented on Mar 5, 2023

    @BNolet

    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.

  10. ScottG489 commented on Mar 8, 2023

    @ScottG489
    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.

  11. VNRARA commented on Mar 19, 2023

    @VNRARA

    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.

  12. ScottG489 commented on Mar 20, 2023

    @ScottG489
    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.

  13. VNRARA commented on Mar 20, 2023

    @VNRARA

    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.

  14. ScottG489 commented on Mar 20, 2023

    @ScottG489
    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.

  15. Xlinx64 commented on Mar 20, 2023

    @Xlinx64

    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.

  16. 123 remaining items

  17. ScottG489 commented on Oct 15, 2025

    @ScottG489
    Author
  18. removed
    staleThere has not been activity on this issue or PR for quite some time.
    on Oct 16, 2025
  19. github-actions commented on Nov 16, 2025

    @github-actions
  20. added
    staleThere has not been activity on this issue or PR for quite some time.
    on Nov 16, 2025
  21. DarkFox commented on Nov 16, 2025

    @DarkFox
  22. added
    no-staleThis issue or PR is exempted from the stable bot.
    and removed
    staleThere has not been activity on this issue or PR for quite some time.
    on Nov 16, 2025
  23. frenck commented on Nov 16, 2025

    @frenck
    Member

    Upstream I've been able to implement a bunch of fixes / mitigations that should help as of the next release:

    That should drastically improve CPU usage; and memory usage as a side-effect. For protection, I'm also modifying the add-on to prevent the use of the / root folder as the workspace (which consumes a metric TON of memory if done that way).

    While not a full memory leak fix, it will mitigate the issue. I have a few places that potentially leak in the upstream vscode extension that I'm looking into.

    ../Frenck

                           

    Blogging my personal ramblings at frenck.dev

  24. frenck commented on Nov 16, 2025

    @frenck
    Member

    Please try the latest release: https://github.com/hassio-addons/addon-vscode/releases/tag/v6.0.0

    I'm curious to learn if things improved.

    ../Frenck

                           

    Blogging my personal ramblings at frenck.dev

  25. ScottG489 commented on Dec 10, 2025

    @ScottG489
    Author

    Just as a quick update on this: I've been occasionally taking a look at historical memory usage and comparing the before/after relative to the update. I don't really have anything conclusive to report yet. While I haven't seen any run-away usage like before, my usage of the add-on has been limited.

    If anyone else can take a look at memory usage before/after v6 and provide their own feedback, that would be helpful :)

    Edit: Another data point - my automation to restart VSCode if it's memory gets too high just triggered. It seemed to suddenly spike. I've disabled the automation for now so I can more easily track memory.

  26. multinet33 commented on Jan 20, 2026

    @multinet33

    hello

    @ScottG489 i use vscode 6.0.1 on home assistant Yellow (raspi 4 4Go RAM) and i have a lot of HIGH memory and high CPU usage. On my side I have to reboot HA to recover CPU @ 15 to 18% and memory @ 50 to 55% (huge HA config this more than 400 template sensors and 100 zigbee hardware and about 60 integrations)

  27. bcutter commented on Jan 20, 2026

    @bcutter

    As a workaround and

    • just in case I accidentally discover the increased memory usage after using Studio Code Server
    • or I get a notification of my "80 % total system memory is in use, check situation" automation - triggered once a few days ago after years of silence

    I restart the Studio Code Server addon. Pretty easy with the switches available for a few HA releases now.

    image

    Of course it would be much better if the Supervisor / addons internal mechanisms can take care of the addons memory hunger.

    image

    • Blue Studio Code Server addon memory usage
    • Yellow system memory usage

    Pretty obvious right.

  28. ScottG489 commented on Jan 20, 2026

    @ScottG489
    Author

    It's a bit tricky because you're running a full on and fairly heavy IDE application as an add-on. I don't think it's completely unexpected that it might have high memory usage. But it should not grow unbounded and perhaps should regulate itself to free up memory when not in use.

  29. Dillton commented on Jan 21, 2026

    @Dillton

    The problem from my observation must be somewhere in the session manager or something like this.
    I mentioned this last year here in this very issue. I don't know if it got lost between the comments but it's here somewhere.
    Anyway the way I found this was observation of Connected Clients to HA via:

    websocket_api:
    - platform: websocket_api
      name: Connected Clients
      unique_id: connected_clients

    It was very strange when I noticed for the first time that I had so many clients (over 20) connected so I was counting every device or app which could be connected to my HA and still the number was not correct. However everything worked so I was thinking maybe the sensor just gives incorrect data and moved this issue for future debugging. Then I noticed few days later the RAM was completely consumed and started looking who or what is consuming all of it. Found the VSCode add-on as causer. Restarted it and then I saw also connected clients dropped to a number of 5 clients. It was clear that this number dropped exactly when VSCode was restarted.

    So if you will observe this sensor together with VSCode RAM usage you will see both will start growing overtime you use VSCode. For example as already mentioned I had over 20 connected clients based on the sensor and RAM fully consumed. Once I restarted the add-on the RAM of course drops to 0.x% but also Connected Clients returns to correct value which in my case is 5. But the 15+ sessions were opened by VSCode somehow.

    I am thinking a good explanation would be that new session is opened every time you access VSCode from a new browser tab for example and then once it's closed the session remains open. This would mean there is missing some session close trigger based on time of inactivity or it's there but has some problem. Maybe there should be also some function which will use the same session if you use the same browser on the same device but multiple tabs. IDK I am not a developer but this pointed me at least somewhere and tried to summarize my observation and thoughts here.

    Maybe it will help us move closer to the solution. 😊

    UPDATE: Fresh example few minutes old. You can see that drop at 10:18 in both sensors thats the spot I restarted VSCode. Unfortunatelly I am not tracking history of VSCode usage but overall RAM usage dropped by 10% and connected clients from 18 to 6.
    Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-staleThis issue or PR is exempted from the stable bot.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions