PowerShell / Polaris

A cross-platform, minimalist web framework for PowerShell
https://powershell.github.io/Polaris/
MIT License
512 stars 114 forks source link

Possible Memory leak #218

Open dwinshipIdentifi opened 3 years ago

dwinshipIdentifi commented 3 years ago

Polaris Bug Report

Description of the bug

We have Polaris running in a windows container and over time it is consuming more memory.

A clear and concise description of what the bug is.

Steps to reproduce

Steps to reproduce the behavior: Start Polaris as a windows container and monitor memory. At this point we aren't actively using the REST API.

Expected behavior

Start container and the amount of memory to start the process should be used and stay at a consistent amount.

Additional context

Dockerfile we are using FROM mcr.microsoft.com/powershell:lts-nanoserver-1809

USER ContainerAdministrator

RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"

SHELL ["pwsh", "-Command"]

COPY artifacts C:

RUN ["pwsh.exe", "C:\bootstrap.ps1"]

Expose 8080

cmd C:\Invoke-Polaris.ps1

Entrypoint Script Import-Module Polaris New-PolarisGetRoute -Path "/test" -Scriptblock { $Response.Send('DEVOPSAPI is running'); }

New-PolarisGetRoute -Path "/customers" -Scriptblock { $getCust = "C:\scripts\get-customers.ps1" | Invoke-Expression $Response.Json($getCust); }

New-PolarisGetRoute -Path "/customers/:cid/workflows" -Scriptblock { $cid = $Request.Parameters.cid $getWFs = "C:\scripts\get-workflows.ps1 -CID $cid" | Invoke-Expression $Response.Json($getWFs); }

New-PolarisGetRoute -Path "/customers/:cid/workflows/:wfkey/steps" -Scriptblock { $cid = $Request.Parameters.cid $wfkey = $Request.Parameters.wfkey $getSteps = "C:\scripts\get-workflow-steps.ps1 -CID $cid -WFKEY $wfkey" | Invoke-Expression $Response.Json($getSteps); }

$app = Start-Polaris

while($app.Listener.IsListening) { Wait-Event callbackcomplete }

Version Information


Run the following script and copy and paste the results here:

$Version = [pscustomobject]$PSVersionTable
$Version.PSCompatibleVersions = ($Version.PSCompatibleVersions | foreach { "$($_.Major).$($_.Minor).$($_.Build).$($_.Revision)" }) -join ",  "
(Get-Module Polaris | select Name,Version | ConvertTo-Html -Fragment | Out-String) + ($Version | ConvertTo-Html -Fragment | Out-String)
lybomir-dobrynin commented 3 years ago
PSVersionPSEditionPSCompatibleVersionsBuildVersionCLRVersionWSManStackVersionPSRemotingProtocolVersionSerializationVersion
5.1.14393.4583Desktop1.0.-1.-1, 2.0.-1.-1, 3.0.-1.-1, 4.0.-1.-1, 5.0.-1.-1, 5.1.14393.458310.0.14393.45834.0.30319.420003.02.31.1.0.1

Memory leak is true