You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.WG-Cmdletsgeneral cmdlet issuesWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance
I don't know what "eventually it was killed" means or where "actual behavior" animation comes from.
But this sounds like the CLR is not collecting free'd memory quick enough. You can alleviate this to some degree by inserting '[gc]::Collect()' into your loop.
Or, you can use the new foreach-object -parallel that re-uses runspaces, which greatly reduces memory use. It has been checked into the preview 1 branch, but is not yet part of the preview release. I am not sure when the preview release will be updated but you can clone the master branch and build it yourself if you want to try it out.
The new foreach-object -parallel re-uses runspaces by default but you can revert to the previous behavior by selecting the -UseNewRunspace parameter switch. You can also verify that you are using the new version of foreach-object -parallel by checking if this parameter switch is available.
# Runspace reuse is automatic1..1000|foreach-object-parallel { "Hello: $_" }
# Revert to old behavior where new runspace is created/discarded for each loop iteration1..1000|foreach-object-parallel { "Hello: $_" } -UseNewRunspace
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.WG-Cmdletsgeneral cmdlet issuesWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance
Activity
iSazonov commentedon Apr 6, 2020
/cc Paul Higinbotham (@PaulHigin)
PaulHigin commentedon Apr 6, 2020
I don't know what "eventually it was killed" means or where "actual behavior" animation comes from.
But this sounds like the CLR is not collecting free'd memory quick enough. You can alleviate this to some degree by inserting '[gc]::Collect()' into your loop.
Or, you can use the new foreach-object -parallel that re-uses runspaces, which greatly reduces memory use. It has been checked into the preview 1 branch, but is not yet part of the preview release. I am not sure when the preview release will be updated but you can clone the master branch and build it yourself if you want to try it out.
See: PR #12122
The new foreach-object -parallel re-uses runspaces by default but you can revert to the previous behavior by selecting the
-UseNewRunspaceparameter switch. You can also verify that you are using the new version of foreach-object -parallel by checking if this parameter switch is available.