Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
5  
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
2  
-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
1  
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

1 Answer 1

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

 
discard

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.