Skip to content

Memory leak until the system freezes #2171

Description

@DarkLite1

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 PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
  • I have verified that I am using the latest version of PowerShell Editor Services.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Every time the extension "PowerShell v2024.3.2 (pre-release)" is enabled, the memory usage goes up until the system freezes. When disabling the extension, there is no issue. Same issue with the release version "Powershell 2024.2.2".

Also reported here.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.4
PSEdition                      Core
GitCommitId                    7.4.4
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Editor Version

vs code 1.92.1
eaa41d57266683296de7d118f574d0c2652e1fc4
x64

Name             : ConsoleHost
Version          : 7.4.4
InstanceId       : b1eb55a6-5f37-4759-bc50-59721354e6d5
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

PowerShell Editor Services Version

The one built-in to "PowerShell v2024.3.2 (pre-release)" and "Powershell 2024.2.2".

Steps to Reproduce

Every time the extension "PowerShell v2024.3.2 (pre-release)" is enabled, the memory usage goes up until the system freezes. When disabling the extension, there is no issue. Same issue with the release version "Powershell 2024.2.2".

Simply enable the extension, open VS Code and wait for the RAM to be fully consumed. No coding required.

Visuals

Screenshot 2024-08-14 090503
Screenshot 2024-08-14 085556
Screenshot 2024-08-14 085522
Screenshot 2024-08-14 085436
Screenshot 2024-08-14 085401
Screenshot 2024-08-14 085357

Logs

1723619554-68a1cfd5-1a3e-43e5-9fc4-7e8fa8a133561723619552104.zip

Activity

  1. andyleejordan commented on Aug 19, 2024

    @andyleejordan
    Member

    Hi, can you try setting "enable script analysis on open files only" and let me know if it's still reproduces? We often see a large memory increase like this when a user has opened a folder that contains many thousands of PowerShell scripts (such as your home folder) and the default setting to analyze them all just takes a lot of memory.

  2. DarkLite1 commented on Aug 20, 2024

    @DarkLite1
    Author

    Thank you Andy Jordan (@andyleejordan) , that seems to solve the issue. Very annoying... Thx for the workaround.

    I'll leave this one open as I think this should never happen, a freezing system because of a setting that is not set.

  3. andyleejordan commented on Aug 23, 2024

    @andyleejordan
    Member

    Sydney Smith (@SydneyhSmith) Patrick Meinecke (@SeeminglyScience) what do we think about changing this setting to be enabled by default? I think it would fix more issues than it would cause.

  4. SydneyhSmith commented on Aug 23, 2024

    @SydneyhSmith
    Collaborator

    I would be interested to test that out in preview and see if there is unexpected behavior

  5. JustinGrote commented on Aug 24, 2024

    @JustinGrote
    Collaborator

    My two cents would be to not make it default behavior, but have an upper limit of files being analyzed where it pops up a warning and offers to turn off the setting, the upper limit being another setting thats configurable, maybe start at 500 or something.

  6. DarkLite1 commented on Aug 26, 2024

    @DarkLite1
    Author

    My two cents would be to not make it default behavior, but have an upper limit of files being analyzed where it pops up a warning and offers to turn off the setting, the upper limit being another setting thats configurable, maybe start at 500 or something.

    Or simply check the memory consumption once in a while for pwsh.exe process launched by the extension. If it goes above 2 GB, something is definitely wrong.

  7. JustinGrote commented on Aug 26, 2024

    @JustinGrote
    Collaborator

    My two cents would be to not make it default behavior, but have an upper limit of files being analyzed where it pops up a warning and offers to turn off the setting, the upper limit being another setting thats configurable, maybe start at 500 or something.

    Or simply check the memory consumption once in a while for pwsh.exe process launched by the extension. If it goes above 2 GB, something is definitely wrong.

    Not necessarily, since scripts run in there and the REPL runs in there, I could very well be running a script that consumes 2GB, the extension process is not used simply for extension purposes (though we often wish it would, this is necessary to provide ISE-like behavior)

  8. andyleejordan commented on Aug 26, 2024

    @andyleejordan
    Member

    My two cents would be to not make it default behavior, but have an upper limit of files being analyzed where it pops up a warning and offers to turn off the setting, the upper limit being another setting thats configurable, maybe start at 500 or something.

    You know, I would happily accept a PR for this 🤠

  9. JustinGrote commented on Aug 27, 2024

    @JustinGrote
    Collaborator

    Andy Jordan (@andyleejordan) I'll put it on the very long to-do list :)

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