Repository: vscode
Issue: Hardware acceleration creates memory Leak on 1.96.2; eventually caps RAM and freezes computer
Labels: bug,perf,under-discussion,gpu

<!-- ⚠️⚠️ 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?: Yes

<!-- 🪓 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: See title.
- Portable version
- OS Version: Windows 11 Pro 24H2

Spun off from issue #230090 which was closed without investigating / solving the issue. I voiced my frustration that the bug got closed within a week while I was on holiday after I've waited 3 months for an answer. Please don't do the same with this bug.

Steps to Reproduce:

1. Launch VS Code with no extension enabled, but hardware acceleration enabled
2. Wait

What happens:

1. RAM usage constantly increases
2. Developer: Process Explorer does not report any usage increase on any of the code main items
3. Eventually the RAM usage caps out, the computer becomes unresponsive, and I have to hard reset it

What I have tried, unsuccessfully:

1. Reinstalled VS Code entirely and re-synced to my Github profile
2. Disabled all extensions
3. Uninstalled all extensions

What I have tried, **successfully**:
1. Disable hardware acceleration in `argv.json` and restart VSCode. Memory leak does not occur.

Memory report from Windows Task Manager as VS Code uses more than 4GB of memory:
![Image](https://github.com/user-attachments/assets/596cba13-d0ed-45ec-976f-2f7267fe3d56)

Memory usage at the same time as the above:
![Image](https://github.com/user-attachments/assets/cb9a94b7-b214-433c-af6a-82623b992c46)

Developer tools report:
![Image](https://github.com/user-attachments/assets/fbe40722-7393-4e3d-8a4f-510f82e8fe0e)

FWIW, adding screenshot of VSCode version:
![Image](https://github.com/user-attachments/assets/fe75c6f6-7a58-4bfa-9b3a-69e621ce429b)

Immediately after closing VSCode:
![Image](https://github.com/user-attachments/assets/89367d29-b806-446a-a911-310f399ef229)

Command line used to launch the software:
`"D:\Users\Mighty\Dropbox\Software\Windows\Tools\VSCode-win32-x64\Code.exe" `

I noticed page faults are constantly increasing:
![Image](https://github.com/user-attachments/assets/6ba166dd-d91e-4882-8c58-81a6cf01d377)

I noticed that one of the subprocesses of Code.exe has a constant use of CPU (6.20).
The associated command line is: `"D:\Users\Mighty\Dropbox\Software\Windows\Tools\VSCode-win32-x64\Code.exe" --type=gpu-process --user-data-dir="C:\Users\Mighty\AppData\Roaming\Code" --gpu-preferences=UAAAAAAAAADgAAAMAAAAAAAAAAAAAAAAAABgAAEAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAA --field-trial-handle=1784,i,2806485216046023221,10863828599728893653,262144 --disable-features=CalculateNativeWinOcclusion,PlzDedicatedWorker,SpareRendererForSitePerProcess,WinDelaySpellcheckServiceInit,WinRetrieveSuggestionsOnlyOnDemand --variations-seed-version --mojo-platform-channel-handle=1768 /p`

Below, the stack of the thread that uses that 6.20 CPU amount. Note that I have no idea if it is the thread that is problematic.
```
0x0000000000000000
ntdll.dll!NtFsControlFile+0x14
KERNELBASE.dll!WaitNamedPipeW+0x269
NvMessageBus.dll!releaseMessageBusInterface+0x4bb05
NvMessageBus.dll!releaseMessageBusInterface+0x49a8a
NvMessageBus.dll!releaseMessageBusInterface+0x22f4b0
KERNEL32.DLL!BaseThreadInitThunk+0x17
ntdll.dll!RtlUserThreadStart+0x2c
```

Memory usage reported by ProcessExplorer is basically stable and not increasing for Code.exe, but at the same time my RAM is getting filled more and more and more as the process is running.

If you need anything else, please let me know.