Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

BashCow Latest Questions

  • 10
  • 10
clifton.schowalter

Difference between executing commands together using & and running them sequentially?

If I need to execute several computationally intensive commands in the Windows command line, does it impact performance if I combine them using &

doSomething1 & doSomething2 & doSomething3

versus running them individually:

doSomething1
doSomething2
doSomething3

I am worried that chaining too many commands with & might eventually exhaust my memory.

Related Questions

1 Answer

  1. No, it doesn't make a difference. If you're using Cmd.exe, most of your commands are external, meaning they start an .exe as a separate process. This means their memory allocation only exists while the .exe is running. Once the process finishes, all of its resources (allocated memory, open files, etc.) are automatically cleaned up by the OS, not by Cmd.exe. In other words, resource cleanup is handled by your OS process management, not by the command shell, and the way you structure the command line doesn't affect it. This concern would be more relevant for commands that are internal to the shell. Cmd.exe has very few internal commands, whereas PowerShell allows for building large data structures within the shell's process. In theory, if you have PowerShell functions or cmdlets that handle large amounts of data, their objects might persist after the function returns. However, the CLR runtime will eventually perform garbage collection before it becomes a significant issue.

    No, it doesn’t make a difference.

    If you’re using Cmd.exe, most of your commands are external, meaning they start an .exe as a separate process. This means their memory allocation only exists while the .exe is running.

    Once the process finishes, all of its resources (allocated memory, open files, etc.) are automatically cleaned up by the OS, not by Cmd.exe.

    In other words, resource cleanup is handled by your OS process management, not by the command shell, and the way you structure the command line doesn’t affect it.

    This concern would be more relevant for commands that are internal to the shell. Cmd.exe has very few internal commands, whereas PowerShell allows for building large data structures within the shell’s process.

    In theory, if you have PowerShell functions or cmdlets that handle large amounts of data, their objects might persist after the function returns. However, the CLR runtime will eventually perform garbage collection before it becomes a significant issue.

    See less
Leave an answer

Leave an answer