Product: PowerShell Universal
Version: 5.6.8
I have been noticing our PSU cluster failing to respond to API calls after about a month of continuous operation which ultimately culminates in a System.OutOfMemoryException error. At first I thought this might be an issue with how my scripts are handling things like importing pssessions, so I cleaned up that and I started monitoring and logging the memory usage by the PowerShellUniversal process. I started seeing specifically a handle leak coming from Universal.Server.exe
Here is my AI-assisted summary below lol
Summary
Universal.Server.exe shows steadily increasing handle count over time.
Details
Using Process Explorer, the dominant handle type is Thread.
Many thread handles reference <Non-existent Process>, indicating thread handles are not being closed after the worker process exits.
Observations
- Host processes recycle normally
- Leak is isolated to Universal.Server.exe
- Restarting the Server process resets handle count
- Handles increase again with uptime
Impact
Long-lived server eventually approaches handle limits.