Unloading the module leaks a RunspacePool
Closed this issue · 0 comments
oising commented
Due to #34 , unloading the module with remove-module polaris
will leave the global variable $polaris
and associated disposable RunspacePool
field in memory. The Polaris
class would be better modeled as a singleton, and be made disposable. Consider adding a hook for module removal to dispose the singleton; here's an interactive example:
PS C:\> new-module -Name foo {
$m = $ExecutionContext.SessionState.Module;
$m.OnRemove = {
# [polaris]::cleanup()
write-host "bye from $($m.Name)"
}.GetNewClosure()
} | import-module
PS> remove-module foo
bye from foo