+Red King Subscriber² Posted August 11, 2016 Subscriber² Share Posted August 11, 2016 I don't get this, cmd /c " `"mysqldump.exe`" .. > $foo " # vs .\mysqldump.exe .. > $foo PS process eats all my memory when using .\foobar.exe whereas going using cmd /c "foobar.exe" does not. What the ###### is happening here? Ideas? Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/ Share on other sites More sharing options...
0 +rdlenk Subscriber² Posted August 11, 2016 Subscriber² Share Posted August 11, 2016 Does the effect change at all if you use Start-Process? goretsky 1 Share Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/#findComment-597537456 Share on other sites More sharing options...
0 +Red King Subscriber² Posted August 11, 2016 Author Subscriber² Share Posted August 11, 2016 2 hours ago, rdlenk said: Does the effect change at all if you use Start-Process? I think that did the trick! I think PS tried storing the file in memory before writing it to disk with the ">" op, With Start-Process and -RedirectStandardOutput - it does not try to store the file in memory. Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/#findComment-597537820 Share on other sites More sharing options...
0 +rdlenk Subscriber² Posted August 11, 2016 Subscriber² Share Posted August 11, 2016 I don't think PowerShell likes using ">" anyways. Should be something like "<command> | Write-Output <filename>" or something like that. Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/#findComment-597537882 Share on other sites More sharing options...
0 +Red King Subscriber² Posted September 9, 2016 Author Subscriber² Share Posted September 9, 2016 I need some follow up tips. I noticed that Start-Process executes slower than "cmd /c" - any reason for that? Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/#findComment-597578572 Share on other sites More sharing options...
0 +Red King Subscriber² Posted August 30, 2017 Author Subscriber² Share Posted August 30, 2017 10 hours ago, Riva said: In both scenarios foobar.exe is a child process of either powershell or cmd instance. Powershell is a managed process (.NET CLR) vs. CMD which is native app. Native apps have a lighter footprint and higher processor resolution. .NET CLR (and Java) tend to use a virtualised CPU in order to ensure type safety. .NET native solves this problem but it isnt as widely implemented yet. I don't think that explains it. I mean there is a difference between native and .NET but its minor for non-performance critical code. Like Start-Process just executes another executable and waits for it - so not much runs in .NET CLR anyway here. As far as I remember (this topic is from a year ago and I don't work there anymore) - it just did nothing for a much longer time when launching from Start-Process versus indirectly through CMD. Like it wasn't an issue with higher process utilization - mysqldump through Start-Process was simply doing ######-all for a long time. Link to comment https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/#findComment-598013194 Share on other sites More sharing options...
Question
+Red King Subscriber²
I don't get this,
cmd /c " `"mysqldump.exe`" .. > $foo " # vs .\mysqldump.exe .. > $foo
PS process eats all my memory when using .\foobar.exe whereas going using cmd /c "foobar.exe" does not.
What the ###### is happening here? Ideas?
Link to comment
https://www.neowin.net/forum/topic/1305452-powershell-lower-memory-consumption-when-using-cmd-c-instead-of-to-run-exe/Share on other sites
5 answers to this question
Recommended Posts