Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am well aware on how to drop (e.g. /sbin/sysctl vm.drop_caches=3 ) caches in Linux, but for benchmarking I'd like to do the reverse, fill up the caches up to 100% RAM if possible. How would I do that pragmatically?

share|improve this question
Try just reading all the bits in the file system until cache usage seems to high water-mark: find / -type f -exec md5sum {} \; – MadHatter Aug 29 '13 at 10:11
-exec cat {} >>/dev/null would use less CPU – symcbean Aug 29 '13 at 10:17
Grumble. Not only are you a CPU cheapskate, you're right, as well. – MadHatter Aug 29 '13 at 10:29
Why are you commenting instead of clicking answer button to give a proper answer I can mark up as the right one? =) – Dima Aug 29 '13 at 11:49

Here's how to consume RAM for 5 minutes (300 seconds).

perl -e '$a = "A" x 1_000_000_000; sleep 300' &

Open two terminals / shells;

  1. Run 'top'

  2. Start running multiples of the above command till you hit the usage you desire.

Note you might have to adjust the amount of seconds (5 min = 300, 1 hour = 3600)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.