PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.67k stars 292 forks source link

PSReadLine: 2.3.4 PowerShell: 7.5.0-preview.2: System.OutOfMemoryException #4066

Closed konradbielik closed 2 weeks ago

konradbielik commented 1 month ago

Prerequisites

Exception report

Right after installing prerelease ver of PSReadLine and opening termninal i get:

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.3.4
PowerShell: 7.5.0-preview.2
OS: Microsoft Windows 10.0.19045
BufferWidth: 120
BufferHeight: 30

Last 0 Keys:

### Exception

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at Microsoft.PowerShell.HistoryQueue`1..ctor(Int32 capacity)
   at Microsoft.PowerShell.PSConsoleReadLine.DelayedOneTimeInitialize()
   at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

https://github.com/PowerShell/PSReadLine/assets/89704884/41547ce7-7bed-43a7-8b6a-811fecd47f84

Environment data

PS Version: 7.5.0-preview.2
PSReadLine Version: 2.3.4
OS: Microsoft Windows 10.0.19045
BufferWidth: 120
BufferHeight: 30

Steps to reproduce

1, Install OSReadline v. 2.3.4 and PS 7.5.0-preview.2

  1. Open regular powershell session
  2. You will be spammed by System.OutOfMemoryExceptions

Expected behavior

I want to work without disturb just like with the prev ver

Actual behavior

Oops, something went wrong. Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections. Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml Thank you!

Environment

PSReadLine: 2.3.4 PowerShell: 7.5.0-preview.2 OS: Microsoft Windows 10.0.19045 BufferWidth: 120 BufferHeight: 30

Last 0 Keys:

Exception

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at Microsoft.PowerShell.HistoryQueue1..ctor(Int32 capacity) at Microsoft.PowerShell.PSConsoleReadLine.DelayedOneTimeInitialize() at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics) at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable1 lastRunStatus)

daxian-dbw commented 1 month ago

What is the value you set to MaximumHistoryCount? Did you change the value in profile? The default value is 4096 (or the value of the $MaximumHistoryCount from your PowerShell session). It looks to me your machine is under memory stress which caused creating the history queue to fail with the OutOfMemryException.

https://github.com/PowerShell/PSReadLine/blob/eff1452a647a0bb5863cf5fa42062b3b1f701c10/PSReadLine/ReadLine.cs#L832-L834