PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PowerShell Extension 2023.8.0 paging 5GB memory

mcc85s opened this issue · comments

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

When using the PowerShell Extension in VSCode, the program is paging an excessive amount of memory (up to 5GB), and sometimes it freezes up the console for several minutes.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.3803
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3803
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Name             : Visual Studio Code Host
Version          : 2023.8.0
InstanceId       : fe23a2a4-a30e-472d-ac50-be3dc011cc39
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.85.1
0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
x64

Extension Version

ms-vscode.powershell

Steps to Reproduce

Not sure how to isolate the issue without introducing my work...

Invocation of the first script in PowerShell Desktop console will initialize the installation controller, which will create a variable called $Module. There is a faster way to install it via $Module.Latest(), but there's a POSSIBLE issue with that method until I release a new version. So instead:
PS Prompt:> $Module.Install()

...will get all of the module assets and add it to installed modules.

PS Prompt:> Import-Module FightingEntropy -Verbose -Force

...will import it into the session.

Then, saving https://github.com/mcc85s/FightingEntropy/blob/main/Scripts/2024_0104-(NewVmController).ps1 to a local file and dot sourcing it will get it to load up the utility.

Whenever I use Windows Terminal, I do not experience a sudden rush of 5GB memory being paged to something.
My code editor has only been doing this for about 2-3 weeks, it'll lock up the console, I won't be able to enter anything new into the console for anywhere between 1-15 minutes.

Here's a recent video of me demonstrating the function (networking component only)
https://www.youtube.com/watch?v=b09tQEHeQoA

As for reproduction, I do not think that the function or the module is what's causing the editor to start accumulating additional memory to page to something... but who knows. Sometimes it just happens when I open VSCode and let the console sit around idle.

Visuals

No response

Logs

No response

Most likely your workspace has a lot of PowerShell files being crawled for references, in which case you probably want to set powershell.analyzeOpenDocumentsOnly. Let me know if that helps! Also we made a fix in the pre-release for non-workspaces (like no folder was opened, so the starting directory was getting crawled accidentally).

Alright, I just enabled it.
I think you're right that it does have something to do with files being crawled for references...
But when I tried closing all but (3) tabs I was working on, the console still occasionally hung up on me.
I'll keep you posted to let you know whether or not that worked.