In Bash, set the soft virtual-memory limit for the current shell and future child processes to 524288 KiB.
Do not change the hard limit.
Which command is appropriate?
ulimit -S -v VALUE sets the virtual-memory soft limit in KiB. A soft limit cannot exceed the hard limit.
Detailed explanation
ulimit -S -v 524288Correct. It sets the virtual-memory soft limit to 524288 KiB.
Correct. It sets the virtual-memory soft limit to 524288 KiB.
ulimit -H -v 524288Incorrect. -H changes the hard limit.
Incorrect. -H changes the hard limit.
ulimit -S -m 524288Incorrect. -m refers to resident-set-size limits rather than total virtual memory.
Incorrect. -m refers to resident-set-size limits rather than total virtual memory.
ulimit -S -u 524288Incorrect. -u controls the process-count limit.
Incorrect. -u controls the process-count limit.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-S=soft limit' '-H=hard limit' '-v=virtual memory KiB' '-u=process count'Expected result
-S=soft limit
-H=hard limit
-v=virtual memory KiB
-u=process countKey points
- -S is soft
- -v is virtual memory
- The value is in KiB
Notes
- Environment: Bash ulimitのoption対応表
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.