pwsh.exe process consumes all RAM · Issue #5548 · PowerShell/vscode-powershell · GitHub
Skip to content

pwsh.exe process consumes all RAM #5548

Open

Description

@tstrueber

Type: Performance Issue

The issue occurs consistently after Visual Studio Code has been running for some time with a PowerShell (.ps1) file open.

After some time, one pwsh.exe process continuously increases its memory usage until it consumes nearly all available system RAM. Once this happens, VS Code becomes very slow and eventually unusable.

I have observed this multiple times and it appears to be reproducible during normal PowerShell development.

Extension version: 2025.4.0
VS Code version: Code 1.127.0 (4fe60c8b1cdac1c4c174f2fb180d0d758272d713, 2026-06-30T10:52:33+02:00)
OS version: Windows_NT x64 10.0.20348
Modes:

System Info
Item Value
CPUs Intel(R) Xeon(R) Gold 6254 CPU @ 3.10GHz (6 x 3093)
GPU Status 2d_canvas: unavailable_software
GPU0: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VENDOR=Microsoft, DRIVER_VERSION=10.0.20348.5020 ACTIVE
GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.20348.5020
GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.20348.5020
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: disabled_software
video_encode: disabled_software
webgl: unavailable_software
webgpu: unavailable_software
webnn: unavailable_software
Load (avg) undefined
Memory (System) 64.00GB (0.31GB free)
Process Argv --crash-reporter-id 028721c2-1982-486e-8521-a16aeb27afaa
Screen Reader no
VM 100%
Process Info
CPU %	Mem MB	   PID	Process
    0	   134	  9268	code
    1	   144	  1136	   gpu-process
    0	   144	  2748	shared-process
    0	    30	  3220	   crashpad-handler
    0	   391	  7028	extension-host [1]
    0	   187	 19968	     electron-nodejs (main-bundle-node.js)
    0	   106	 10804	file-watcher [1]
    1	   380	 12380	window [1] (● ex-cmdlets_2026-07.ps1 - SCRIPTS - Visual Studio Code [Administrator])
    0	    46	 19704	   utility-network-service
    0	   134	 20564	pty-host
    0	     8	  1280	     "c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\node_modules\node-pty\build\Release\conpty\OpenConsole.exe" --headless --inheritcursor --width 80 --height 30 --signal 0x5a8 --server 0x5a0
    0	     8	  4520	     "c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\node_modules\node-pty\build\Release\conpty\OpenConsole.exe" --headless --inheritcursor --width 80 --height 30 --signal 0x504 --server 0x4f8
    0	     8	  5488	     "c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\node_modules\node-pty\build\Release\conpty\OpenConsole.exe" --headless --inheritcursor --width 80 --height 30 --signal 0x564 --server 0x55c
    0	   120	  7484	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	     8	  9028	     "c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\node_modules\node-pty\build\Release\conpty\OpenConsole.exe" --headless --width 154 --height 21 --signal 0x65c --server 0x654
    0	   113	  9580	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	   120	 12356	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	   115	 13108	     "C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	     8	 16216	     "c:\Program Files\Microsoft VS Code\4fe60c8b1c\resources\app\node_modules\node-pty\build\Release\conpty\OpenConsole.exe" --headless --inheritcursor --width 154 --height 21 --signal 0x5c0 --server 0x5b8
   17	    40	 19820	     "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -ExecutionPolicy Bypass -Command "Import-Module 'c:\Users\DV886Z1\.vscode\extensions\ms-vscode.powershell-2025.4.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2025.4.0' -BundledModulesPath 'c:\Users\DV886Z1\.vscode\extensions\ms-vscode.powershell-2025.4.0\modules' -EnableConsoleRepl -StartupBanner \"PowerShell Extension v2025.4.0
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
\" -LogLevel 'Warning' -LogPath 'c:\Users\DV886Z1\AppData\Roaming\Code\logs\20260707T103034\window1\exthost\ms-vscode.powershell' -SessionDetailsPath 'c:\Users\DV886Z1\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9268-933764.json' -FeatureFlags @() "
Workspace Info
|  Window (● ex-cmdlets_2026-07.ps1 - SCRIPTS - Visual Studio Code [Administrator])
|    Folder (SCRIPTS): more than 20000 files
|      File types: TXT(6255) LOG(4297) ps1(1692) psm1(1658) dll(1275)
|                  html(1010) xml(806) psd1(589) json(576) ps1xml(567)
|                  other(1275)
|      Conf files: settings.json(1);
A/B Experiments
vsliv368cf:30146710
pythonvspyt551cf:31249601
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
4f60g487:31327383
6abeh943:31336334
envsdeactivate2:31538737
cloudbuttont:31379625
3efgi100_wstrepl:31403338
ddidtcf:31399634
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31466945
8hhj4413:31478653
ge8j1254_inline_auto_hint_haiku:31490510
38bie571_auto:31478678
cp_cls_t_1081:31454832
conptydll_true:31498968
ia-use-proxy-models-svc:31452481
e9c30283:31461165
test_treatment2:31471001
46204921:31447328
capi_axe_098a3278:31544981
idci7584:31464702
e3e4d672:31494082
c-26112-aa:31454028
ei9d7968:31496641
nes-extended-on:31455476
chat:31457767
8hig5102:31480529
89g7j272:31518289
7e187181:31503455
i2gc6536:31499202
52612955:31516516
githubstableflight:31469463
ghj88844:31499326
ec1eg703:31520046
ddid_t:31478206
hmra_i5g22:31518061
7df3h592:31512476
cp_cls_t_1082:31535311
logging_enabled_new:31498466
j0d79568:31499440
jb_cp_cls_t_632:31543129
748c7209:31512887
32d76977:31512328
ha629193:31508444
cdk-lw-on:31524445
f9bf7985:31543584
31fi7170_t:31522396
jh5f2457_c:31540921
g4a0e106:31529594
8hfba999:31537718
jbcp_cls_pctr_t:31531130
61138546:31518536
cp_intellij_c_nes:31533503
gf14b233:31526830
nes-curr-leftover-1500:31538366
h561g132:31533256
sessions_5:31532894
ihg5j128:31534457
jh7i3328:31546038
9gg7f176:31542112

PS C:\Windows\System32> Get-Process -ProcessName pwsh | ft -a

NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName


85    114,81     81,90    10,39  7076  0 pwsh
65     57,10    117,10     3,33  7484 10 pwsh
73     72,53    141,10     6,00  8600 10 pwsh
59     54,66    110,71     1,44  9580 10 pwsh
62     57,23    115,78     2,47 11184  7 pwsh
65     57,08    116,98     3,08 12356 10 pwsh

167 230,21 160,52 25,38 12976 0 pwsh
64 54,97 114,86 2,95 13108 10 pwsh
175 160,12 304,86 25,58 13268 7 pwsh
86 107,20 80,16 10,44 13944 0 pwsh
59 55,14 110,96 1,36 16012 7 pwsh
217 53.716,83 53.286,51 2.147,56 19820 10 pwsh

PS C:\Windows\System32> Get-Process -Id 19820

NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName


217 ….716,83  53.286,64   2.147,56   19820  10 pwsh

PS C:\Windows\System32> Get-Process -Id 19820 | fl *

Name : pwsh
Id : 19820
PriorityClass : Normal
FileVersion : 7.6.3.500
HandleCount : 958
WorkingSet : 40521728
PagedMemorySize : 491606016
PrivateMemorySize : 491606016
VirtualMemorySize : 1833742336
TotalProcessorTime : 00:35:47.5625000
SI : 10
Handles : 958
VM : 2342590918656
WS : 55875096576
PM : 56326180864
NPM : 222208
Path : C:\Program Files\PowerShell\7\pwsh.exe
CommandLine : "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -ExecutionPolicy Bypass -Command "Import-Module
'c:\Users\DV886Z1.vscode\extensions\ms-vscode.powershell-2025.4.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1';
Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2025.4.0' -BundledModulesPath
'c:\Users\DV886Z1.vscode\extensions\ms-vscode.powershell-2025.4.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension
v2025.4.0
Copyright (c) Microsoft Corporation.

                         https://aka.ms/vscode-powershell
                         Type 'help' to get help.
                         \" -LogLevel 'Warning' -LogPath 'c:\Users\DV886Z1\AppData\Roaming\Code\logs\20260707T103034\window1\exthost\ms-vscode.powershell'
                         -SessionDetailsPath 'c:\Users\DV886Z1\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9268-933764.json'
                         -FeatureFlags @() "

Parent : System.Diagnostics.Process (Code)
Company : Microsoft Corporation
CPU : 2147,5625
ProductVersion : 7.6.3 SHA: 4061323c4e021bea0a08e753f13df015fed607e5+4061323c4e021bea0a08e753f13df015fed607e5
Description : PowerShell 7
Product : PowerShell
__NounName : Process
SafeHandle : Microsoft.Win32.SafeHandles.SafeProcessHandle
Handle : 1288
BasePriority : 8
ExitCode :
HasExited : False
StartTime : 07.07.2026 10:30:40
ExitTime :
MachineName : .
MaxWorkingSet : 1413120
MinWorkingSet : 204800
Modules : {System.Diagnostics.ProcessModule (pwsh.exe), System.Diagnostics.ProcessModule (ntdll.dll), System.Diagnostics.ProcessModule
(KERNEL32.DLL), System.Diagnostics.ProcessModule (KERNELBASE.dll)…}
NonpagedSystemMemorySize64 : 222208
NonpagedSystemMemorySize : 222208
PagedMemorySize64 : 56326180864
PagedSystemMemorySize64 : 833232
PagedSystemMemorySize : 833232
PeakPagedMemorySize64 : 57387732992
PeakPagedMemorySize : 1553158144
PeakWorkingSet64 : 56887054336
PeakWorkingSet : 1052479488
PeakVirtualMemorySize64 : 2342619172864
PeakVirtualMemorySize : 1861996544
PriorityBoostEnabled : True
PrivateMemorySize64 : 56326180864
ProcessorAffinity : 63
SessionId : 10
StartInfo :
Threads : {15920, 7508, 10416, 19344…}
VirtualMemorySize64 : 2342590918656
EnableRaisingEvents : False
StandardInput :
StandardOutput :
StandardError :
WorkingSet64 : 55875096576
SynchronizingObject :
MainModule : System.Diagnostics.ProcessModule (pwsh.exe)
PrivilegedProcessorTime : 00:08:47.6562500
UserProcessorTime : 00:26:59.9062500
ProcessName : pwsh
MainWindowHandle : 0
MainWindowTitle :
Responding : True
Site :
Container :

Activity

  1. github-actions commented on Jul 7, 2026

    @github-actions
    Contributor

    PSES process memory grows unboundedly (~56 GB WS) in a large workspace (>20 000 files), eventually making VS Code unusable.

    For maintainers

    Reproducibility
    The report is actionable as written. Key facts:

    • Extension: 2025.4.0 | VS Code: 1.127.0 | PowerShell: 7.6.3 | OS: Windows Server 2022 (10.0.20348)
    • Workspace: >20 000 files, including 1 692 .ps1 and 1 658 .psm1 files.
    • The offending process is unambiguously PSES (PID 19820, command line confirms Start-EditorServices): PM ≈ 56 GB, WS ≈ 55 GB, CPU ≈ 35 min.
    • Author states it is consistently reproducible "after some time" of normal editing — consistent with an incremental leak during workspace analysis/indexing.
    • Confidence that the report contains enough to reproduce: high (versions, workspace scale, and process data all provided). Exact reproduction steps (which scripts are open, whether analysis is enabled) are not specified, but the workspace size alone is likely the key trigger.

    Copilot-fix suitability — No
    The leak is almost certainly inside PowerShell Editor Services (C#), likely in workspace symbol indexing or PSScriptAnalyzer's background analysis loop over thousands of files. Diagnosing requires a .NET memory profiler against a live PSES process; the fix would be in PowerShellEditorServices, not in this TypeScript extension. This is outside the scope of a well-scoped Copilot coding-agent task.

    Likely area

    • Primary: PowerShellEditorServices — workspace symbol/file indexing or PSScriptAnalyzer background-analysis pipeline. With 3 350 PowerShell files in scope, any per-file data structure that is never evicted will grow without bound.
    • Relevant PSES subsystems to investigate: WorkspaceService, AnalysisService / PSScriptAnalyzer integration, and any file-watcher or symbol-cache that accumulates entries for every file in the workspace.
    • The VS Code extension side (src/features/) is unlikely to be the root cause; the extension simply spawns PSES and relays LSP messages.
    Suggested next steps
    1. Capture a memory dump of the PSES process once it grows large and analyze with dotMemory / WinDbg to identify which .NET type is accumulating.
    2. Check whether disabling Script Analysis (powershell.scriptAnalysis.enable: false) or adding the workspace to powershell.scriptAnalysis.settingsPath exclusions stops the leak — this would narrow the root cause to the PSScriptAnalyzer pipeline.
    3. Consider whether files.exclude / powershell.analyzeOpenDocumentsOnly can be advised as a workaround for users with very large workspaces.
    4. File or link a tracking issue in PowerShellEditorServices once the component is confirmed.

    Related closed issues: #1552 (PSES high memory, closed 2023), #2627 (language features stop working, closed 2020) — neither is an exact match; both were resolved but the underlying analysis-at-scale concern may have regressed or manifested differently here.

    Generated by Agentic Issue Triage for issue #5548 · 75.3 AIC · ⌖ 21.5 AIC · ⊞ 24.2K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@2f03fdaafb8c1ae62dfde7e0be762a822a201aeb
    
  2. tstrueber commented on Jul 8, 2026

    @tstrueber
    Author

    pwsh_fix.zip Man, that memory leak is a total pain. I ran into the same thing where pwsh just eats all my RAM for no reason. I found a way to patch the heap allocation issue in the extension host so it stops ballooning like that.

    downloading this zip file results in "Virus detected" on my client...

  3. github-actions commented on Jul 8, 2026

    @github-actions
    Contributor

    Caution

    agentic threat detected
    Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

    Details

    Potential security threats were detected in the agent output.

    Review the workflow run logs for details.

    ⚠️ Malware Warning: The pwsh_fix.zip file attached in the comment above (by @nuracabo31) has been flagged as containing a virus by Timo (@tstrueber)'s antivirus software. Do not download or execute it. This is not an official fix from the extension team.

    A maintainer should review and remove that comment. For legitimate workarounds while this issue is investigated, the triage analysis above suggests trying:

    • Set powershell.scriptAnalysis.enable: false to disable background script analysis, or
    • Use powershell.analyzeOpenDocumentsOnly: true to limit analysis to open files

    These may reduce PSES memory growth in large workspaces.

    Generated by Issue Comment Handler — Intelligent Response Processing for issue #5548 · 33.5 AIC · ⌖ 16 AIC · ⊞ 24.7K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-comment-handler.md@2f03fdaafb8c1ae62dfde7e0be762a822a201aeb
    
  4. tstrueber commented on Jul 10, 2026

    @tstrueber
    Author
    • Set powershell.scriptAnalysis.enable: false to disable background script analysis, or
    • Use powershell.analyzeOpenDocumentsOnly: true to limit analysis to open files

    Those two settings do not help. Memory growth is still happening...

  5. tstrueber commented on Jul 14, 2026

    @tstrueber
    Author

    Justin Grote (@JustinGrote) you closed this issue. Did you include a fix in the new VSCode Powershell Extension or VSCode? Thanks for a short reply!

  6. JustinGrote commented on Jul 16, 2026

    @JustinGrote
    Collaborator

    Timo (@tstrueber) sorry, I mistakenly closed this due to the pwsh zip virus another commenter posted.

    I cannot reproduce your situation, my PSES remains stable memory, but memory bloat could be caused by anything that bloats pwsh in general, such as a bad module, an infinite recursion command discovery, etc.

    What I can suggest is use a .NET memory analyzer such as DotPeek (30 day free trial) to take a look at what specifically is consuming memory. If it's a component of PSES or some cache in PSES, then it's something we can look further into.
    https://www.jetbrains.com/dotmemory/

  7. added and removed
    Needs: TriageMaintainer attention needed!
    Pending: ExternalThis issue is not fixed here, it is fixed in a dependent repo such as PowerShell,PSScriptAnalyzer
    on Jul 16, 2026
  8. fpsheaven commented on Oct 20, 2026

    @fpsheaven

    Same here, on Windows PowerShell 5.1 rather than pwsh. Details in case they help:

    • Versions: extension 2025.4.0, VS Code 1.142.0, Windows 11 Pro 10.0.26300. The language server was running under powershell.exe, not pwsh.exe.
    • Growth: the PowerShell Editor Services process reached about 30 GB private memory (18 GB working set) roughly 7 hours after it started. Memory only went up and was never released.
    • System impact: free RAM dropped to 0.1 GB of 32 GB, and committed memory reached 70 GB of 74 GB. The pagefile grew to 43 GB and disk activity sat at 100% from the paging, which made the whole PC sluggish.
    • Recovery: killing that one process brought back 15 GB of free RAM immediately.
    • Workspace: a large repo with about 11,000 .ps1 files in the workspace folder, almost all untracked tooling and output folders. Only a few scripts were open or being edited.
    • Workaround so far: I set "powershell.analyzeOpenDocumentsOnly": true and "powershell.enableReferencesCodeLens": false. It's too early to say whether that prevents it, so my suspicion is that workspace-wide scanning for references is the trigger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions