vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

`vscode-server` remote SSH memory leak

Open binaryfire opened this issue 1 year ago • 9 comments

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

binaryfire avatar Apr 13 '24 01:04 binaryfire

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.

arfianadam avatar Apr 16 '24 05:04 arfianadam

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

openscript avatar Apr 22 '24 07:04 openscript

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 avatar Apr 24 '24 20:04 AndyMGar

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.

AndyMGar avatar Apr 25 '24 11:04 AndyMGar

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)

roblourens avatar Apr 26 '24 21:04 roblourens

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

AndyMGar avatar Apr 27 '24 11:04 AndyMGar

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?

https://github.com/microsoft/vscode/issues/156690

Ccccx159 avatar Apr 30 '24 05:04 Ccccx159

@bpasero ?

roblourens avatar May 02 '24 04:05 roblourens

Sounds a lot like https://github.com/microsoft/vscode/issues/211462, needs investigation.

bpasero avatar May 02 '24 05:05 bpasero

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

hlpmenu avatar May 17 '24 18:05 hlpmenu

I'm going to merge it into https://github.com/microsoft/vscode/issues/211462, there's some more detail there

roblourens avatar May 17 '24 21:05 roblourens