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

vscode-server remote SSH memory leak #9778

Closed
binaryfire opened this issue Apr 13, 2024 · 11 comments
Closed

vscode-server remote SSH memory leak #9778

binaryfire opened this issue Apr 13, 2024 · 11 comments
Assignees
Labels
ssh Issue in vscode-remote SSH

Comments

@binaryfire
Copy link

binaryfire commented Apr 13, 2024

Hi guys

I've got several different remote SSH folders pinned to VS Code in my task bar. They're all on the same host. I'm experiencing the following issues:

  • When I open each folder a separate vscode-server instance seems to be launched on the host, which results in very high memory usage.
  • When I close the IDE windows, the host memory usage doesn't decrease
  • When I open the same folders again, memory usage increases

So after opening and closing the same remote folders a few times, the remote host runs out of memory and needs a reboot. This screenshot is from the remote host. No VS Code IDE windows are open but vscode-server is using 8GB RAM.

This screenshot was after opening and closing the same 5 remote SSH folders 3-4 times:

image

@VSCodeTriageBot VSCodeTriageBot added the ssh Issue in vscode-remote SSH label Apr 13, 2024
@arfianadam
Copy link

arfianadam commented Apr 16, 2024

I encounter this as well. Closing an editor (connected to code-server) does not stop spawned processes. Immediately re-opening after closing the editor will spawn yet another set of processes, repeat and this doesn't end until your system runs out of memory. I had to manually kill all those process for the time being.

@openscript
Copy link

I've had similar issues. From another issue, which I can not recall right now, I learned that the Follow Symlinks settings caused the issue.

image

@AndyMGar
Copy link

AndyMGar commented Apr 24, 2024

Yes, same issue for me. An ever increasing number of vscode-server processes consuming an ever increasing amount of memory until the inevitable happens.

One issue is that starting a remote-SSH session then using the command "Remote-SHH: Kill VSCode Server On Host..." does not kill all of the vscode processes that have been started. The only way I found to do that was find the parent process of a vestigial vscode process (which will be a "bash" command), kill that process and then kill any remaining vscode-server processes using something like pkill -f vscode-server.

There really needs to be a way to make a remote SSH connection and then to close it down again without this messy stuff. Or is there one that I am missing?

@AndyMGar
Copy link

I've had similar issues. From another issue, which I can not recall right now, I learned that the Follow Symlinks settings caused the issue.

image

I think this may be related to high CPU usage rather than processes that never get killed.

@roblourens
Copy link
Member

Can you share the full command line arguments of the processes that appear to be leaked? If the vscode window exits cleanly, its associated processes should be shut down on the remote (except for the server process which is lives a little longer and is shared with other connected windows)

@AndyMGar
Copy link

AndyMGar commented Apr 27, 2024

Sure. I have taken some time to look at this more carefully as it is hard to see the wood for the trees, and as you say some processes live a little longer than others.

In summary what seems to be happening is that every time I close a vscode window, after making sure I close the remote-ssh session first (I am assuming this is the cleanest way to exit) I am left with a set of node processes. When I open a new remote-ssh session some of these processes get replaced with new ones and when I close down again some remain.

But what seems odd is that one node process never gets removed or replaced, just recreated every time. This is the "fileWatcher" process. This process, and its 11 threads, gets created for each new VSCode remote-ssh session and after existing cleanly remains. On starting a new VSCode remote-ssh a new "fileWatcher" process and a further 11 threads get created. And so on and so on each time I close and start anew.

I have full details in the attached file in case that helps.

VSCodeRemoteSSHIssuepdf.pdf

@Ccccx159
Copy link

Ccccx159 commented Apr 30, 2024

I encountered the same issue using VS Code version 1.88.1 and Remote SSH version 0.110.1. When I close the remote connection in VS Code and then close the VS Code window, the fileWatcher process on the remote server does not stop. Upon reopening VS Code and establishing a remote SSH connection again, a new fileWatcher process is created on the server, resulting in two fileWatcher processes. After repeating this process multiple times, file handles are depleted, and VS Code displays the message 'Visual Studio Code is unable to watch for file changes in this large workspace' (error ENOSPC).

2024-04-30_134825

I found a similar issue in the VS Code repository, where it was mentioned that the problem was fixed in VS Code release 1.70. However, I am still encountering this issue in the latest stable version. Is this a problem with VS Code itself or with the Remote SSH plugin?

microsoft/vscode#156690

@roblourens
Copy link
Member

@bpasero ?

@bpasero
Copy link
Member

bpasero commented May 2, 2024

Sounds a lot like microsoft/vscode#211462, needs investigation.

@hlpmenu
Copy link

hlpmenu commented May 17, 2024

Same issue here...

From what i found it had something to do with filewatcher, but i havent looked into it thaat much.

The cpu usage is not the main issue for me, but the ram usage, it climbs about +1GB per minute to eventually freeze the system to a extent where oom dosent even kick in.

I also found that closing a window or not dosent matter, running a vscode ssh connection makes the cpu spike, and then no matter f you leave it open, close the connection, close the wndow etc, it will leak HUGE amounts of memory.

Yesterday it went up to 32GB ram usage in 10mins

@roblourens
Copy link
Member

I'm going to merge it into microsoft/vscode#211462, there's some more detail there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

9 participants