You can use the stress-ng
tool to perform a stress test on the CPU and memory (virtual memory) of a Linux or Unix system. stress-ng
is a tool that is designed to stress various system components (e.g., CPU, memory, I/O) in order to test their performance and stability.
To use stress-ng
to stress test the CPU and memory on a Linux or Unix system, you will need to install the stress-ng
package. On an Ubuntu system, you can do this using the following command:
sudo apt-get install stress-ng
Once stress-ng
is installed, you can use it to stress test the CPU and memory by running the following command:
stress-ng --vm 2 --vm-bytes 512M
This will create two virtual memory (VM) stressor threads and allocate 512MB of virtual memory for each thread. This will put a heavy load on the system's memory and CPU, and will allow you to test their performance and stability under high load conditions.
You can adjust the number of VM stressor threads and the amount of virtual memory allocated to each thread to suit your specific testing needs. You can also use the --vm-keep
option to prevent the stressor threads from freeing the virtual memory they allocate, which can further increase the load on the system's memory and CPU.
It's worth noting that stress-ng
has many other options and features that can be used to stress various other system components (e.g., CPU, I/O, filesystem). You can use the stress-ng --help
command to see a complete list of options and learn more about how to use the tool.
Finally, it's important to note that stress testing a system can be a demanding and potentially risky process, and can potentially cause system instability.