Here’s a powerful one-liner that allocates 50GB memory and holds it for 600 seconds:
cat <(yes | tr \\\\n x | head -c $((50*1024*1024*1024))) <(sleep 600) | grep n

- Generates a stream of data using
yes, replacing all newlines withxto avoid sparse allocation. - Slices off a fixed amount of data using
head -c, for example,200*1024*1024*1024bytes (200GB). - Feeds that into
cat, along with asleep 60subprocess, so the pipeline stays alive for 60 seconds. - Uses
grep nas a sink — not to match anything, but to consume and retain the memory in an active process. - This pipeline ensures that the data is not just allocated but actively streamed and held in RAM, provoking real memory pressure.
This one-liner can be easily adapted into a short Bash script that increments memory usage step-by-step. Doing so lets you monitor system behavior at different pressure levels.





Leave a comment