FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Change CommandInfoCache to implement IDisposable and clean up the runspace pool by JamesWTruher · Pull Request #1335 · PowerShell/PSScriptAnalyzer · GitHub

Change CommandInfoCache to implement IDisposable and clean up the runspace pool - #1335

Merged
Christoph Bergmeister (bergmeister) merged 8 commits into
PowerShell:masterfrom
JamesWTruher:RunspaceLeakFix
Sep 12, 2019
Merged

Change CommandInfoCache to implement IDisposable and clean up the runspace pool#1335
Christoph Bergmeister (bergmeister) merged 8 commits into
PowerShell:masterfrom
JamesWTruher:RunspaceLeakFix

Conversation

Copy link
Copy Markdown
Contributor

PR Summary

The Helper is recreated with every invocation of Invoke-ScriptAnalyzer which essentially results in a runspace which was not cleaned up for every invocation. I saw 100s of runspaces (ia get-runspace) in my session. I also gave the CommandInfoCache it's own runspace pool and implemented IDisposable in it. Lastly, I've added a test to catch this in the future.

PR Checklist

The Helper is recreated with every invocation of Invoke-ScriptAnalyzer which essentially resulted in a runspace which was not cleaned up for every invocation.
I saw 100s of runspaces (ia get-runspace) in my session. I also gave the CommandInfoCache it's own runspace pool and implemented IDisposable in it.
Lastly, I've added a test to catch this in the future.
Comment thread Engine/Helper.cs Outdated
It no longer needs to be IDisposable
Implement dispose in cache along suggested guidelines

Christoph Bergmeister (bergmeister) commented Sep 12, 2019
edited
Loading

Copy link
Copy Markdown
Collaborator

The new test failed on WMF4 because the Get-Runspace Cmdlet is not available in that PS version. We could either exclude this PS version for that test (given the fix is ps version agnostic I think that would be OK) or maybe there is a lower level method that one can call as an alternative?

This fix shows up implicitly in the build times, which are quite a bit faster when compared to the ones of master (1 minute), and the WMF4 one even 6 minutes. I even remember being realizing that the WMF4 builds started to take quite a bit longer at some point but I just thought that AppVeyor had reduced the VM sizes due it being a legacy image.

I added a few suggestions and have just one question around the maximum number of runspaces to assert against but mostly this PR looks great.

Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>
Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>
Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>
Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks ok, can be merged if the build is green (except for the Ubuntu build)

James Truher (JamesWTruher) changed the title Change helper to implement IDisposable and clean up the runspace pool Change CommandInfoCache to implement IDisposable and clean up the runspace pool Sep 12, 2019
Christoph Bergmeister (bergmeister) merged commit 91eafaf into PowerShell:master Sep 12, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL