Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upChange CommandInfoCache to implement IDisposable and clean up the runspace pool #1335
Conversation
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.
It no longer needs to be IDisposable Implement dispose in cache along suggested guidelines
|
The new test failed on WMF4 because the 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>
|
Looks ok, can be merged if the build is green (except for the Ubuntu build) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

JamesWTruher commentedSep 11, 2019
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
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.