How to generate variable memory load (%) in linux?

by clyde_reichert , in category: General Help , a year ago

How to generate variable memory load (%) in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by alyson_bogan , a year ago

@clyde_reichert 

To generate a variable memory load in Linux, you can use stress-ng, a stress testing tool for Linux systems. It provides various parameters to generate a workload on different system resources, including memory.

  1. Install stress-ng if it's not already installed on your Linux system. You can use package managers like apt or yum to install it. For example, on Ubuntu, run: sudo apt-get install stress-ng
  2. Once installed, you can use the stress-ng command to generate a memory load with a specified percentage. The parameter for memory load is --vm. For example, to generate a 50% memory load on all available CPUs, use the following command: stress-ng --vm 2 --vm-bytes $(awk '/MemAvailable/{printf "%d ", $2 * 0.5;}' < /proc/meminfo)K --vm-method all --verify This command will allocate approximately 50% of available memory and start stressing the system's memory. Note: Adjust the percentage value as per your requirements.
  3. You can monitor the memory usage and system performance during the memory load generation by using commands like top, htop, or free -m. These commands can provide real-time information about memory usage, CPU load, and other system metrics.


Remember to monitor your system closely while generating a variable memory load as it may impact the overall system performance depending on the load intensity and available resources.

by monroe.bahringer , 8 months ago

@clyde_reichert 

It's worth noting that there are additional tools and methods that can be used to generate variable memory loads in Linux. Another tool that can also be utilized for stress testing and generating memory loads is memtest86 or memtest86+.


Memtest86 and Memtest86+ are standalone memory testing apps that are intended to determine if the computer's RAM is working correctly. Although the primary goal of these tools isn't to create a specific memory load percentage, they can assist in stressing the memory subsystem, leading to significant memory usage.


Using these tools involves creating a bootable USB or CD/DVD and booting the test directly on the system. The test will run automatically and put a strain on the memory subsystem. This added load on the memory can help you analyze the system's stability and the RAM’s performance under stress.


Nevertheless, it's essential to remember that stressing the memory using these methods might differ from the direct percentage-based approach shown for stress-ng. The decision on which tool to use will depend on the specific requirements of the memory load testing being performed.