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
  1. Generates a stream of data using yes, replacing all newlines with x to avoid sparse allocation.
  2. Slices off a fixed amount of data using head -c, for example, 200*1024*1024*1024 bytes (200GB).
  3. Feeds that into cat, along with a sleep 60 subprocess, so the pipeline stays alive for 60 seconds.
  4. Uses grep n as a sink — not to match anything, but to consume and retain the memory in an active process.
  5. 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

I’m Yuan

Welcome to the blog of a performance maven in Oracle & MySQL. Feel free to contact me to share and discuss database knowledge.

My 20 Oracle Certifications

A screenshot from certview.oracle.com

My Book

MySQL 8.0 Operations and Optimization

Let’s connect