Windows – High memory usage when opening Powershell prompt

memorypowerpowershellwindows

Whenever I open a Powershell prompt either via the built in shell or through ConEmu, Powershell's memory usage is excessively high – usually around 1.5 Gb.

It's worse opening as an Administrator where it jumps between 1Gb and 2Gb roughly every second.

Removing everything from my ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 file has no effect.

Running [System.Gc]::Collect() takes memory usage down to ~30Mb and it stays that way.

How can I find out what is causing this high usage? Most Powershell memory advice I can find is to do with high usage when running scripts whereas my shell appears to be doing nothing.

Windows 10, Build 1703.

Best Answer

The same issue happened to me today, powershell would pause for about 5 seconds on startup. Turned out it was PSReadline's fault. The command history was too big (about 600MB in my case) and clearing that fixed the issue.

You can find the history file here:

C:\Users\{user}\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline

Edit

Maximum history count can be set like so:

Set-PSReadlineOption -MaximumHistoryCount 1024

Related Question