Repository: vscode
Issue: The VS Code Server with Remote SSH extension or Code Server experiences a memory leak
Labels: bug,freeze-slow-crash-leak,remote,performance

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: In VSCode with Remote SSH extension , Or  Code Server
- OS Version: Connecting Windows to the Linux Server

Phenomenon
The VS Code Server with Remote SSH extension or Code Server experiences a memory leak issue

https://github.com/microsoft/vscode/blob/921f7ca0fc92817f6ab30ecc93850870cd0bd414/src/vs/base/parts/ipc/node/ipc.net.ts#L646 ，
The length of the array '_recordedInflateBytes' only grows over time and is not released unless the entry process is closed.

The snapshot information is as follows:

![Image](https://github.com/user-attachments/assets/962744df-95ee-4d94-b676-52629054a92f)
![Image](https://github.com/user-attachments/assets/6abd9847-70e8-4368-954a-5484b5da12fc)
![Image](https://github.com/user-attachments/assets/baf4403e-3437-4867-832f-30ba151e1546)

```
 PersistentProtocol  <- src\vs\base\parts\ipc\common\ipc.net.ts
  _socket: WebSocketNodeSocket -> 
    _flowManager:WebSocketFlowManager ->
      _zlibInflateStream: ZlibInflateStream ->
        _recordedInflateBytes: VSBuffer[] -> The length of the array only grows with time  (65411 items in heapsnap shot)
```
<!-- Failed to upload "snapshot.png" -->


Steps to Reproduce:

1. In VSCode version 1.94.2 with Remote SSH extension , 
2. disable the 'Use Exec server' option to switch the VSCode server to a WebSocket connection type to reproduce the issue. 
3. Wait for one week and check the entry process.

1. Code Server.
2.  Wait for one week and check the entry process.

Thought：

The recording of inflated bytes results in a memory leak. The Recording inflated bytes is not necessary if the socket will not be sent to ExtensionHost process. The solution is to disable sending the socket to the ExtensionHost process and as a result, the need to write inflated bytes is eliminated. A named pipe can be used to communicate with the ExtensionHost instead of sending a socket.
https://github.com/microsoft/vscode/blob/389bf6c37fb5c3e177abe762656ea8728c2cc3a4/src/vs/server/node/extensionHostConnection.ts#L128
the “_canSendSocket” property is always true for non-Windows platforms. The named pipe is only used on Windows. Are there any problems or concerns?