• 0

[PowerShell] Lower Memory Consumption When using "cmd /c" instead of ".\" to run exe?


Question

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?

5 answers to this question

Recommended Posts

  • 0
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.

 

  • 0
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.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.