Skip to content

#Requires -Modules causes memory leak #24640

@danielniccoli

Description

@danielniccoli

Prerequisites

Steps to reproduce

  1. Create the file memoryleak.ps1 with the following content:
#Requires -Version 7
#Requires -Modules @{ ModuleName="Microsoft.Graph"; ModuleVersion="2.24.0" }

[CmdletBinding()]
param (
    [Parameter()]
    [switch]
    $SayHello
)

if ($SayHello) {
    "Hello!"
} else {
    "I say nothing!"
}
  1. Install the dependency Microsoft.Graph.
  2. Enter into the terminal: memoryleak.ps1 -
  3. Press tab (for autocompletion).

Expected behavior

Autocompletion should find parameter `-SayHello'

Actual behavior

1. Autocompletion will not finish.
2. The current pwsh.exe process starts consuming more and more memory (over 2GB in my case).

Error details

Not available as process must be killed.

Environment data

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

Visuals

The upper process is the relevant one:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions