Thursday, February 22, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 37796  / 2 Years ago, tue, february 8, 2022, 6:20:17

I'm testing my system with zram, I need a script that will use as much ram as possible. This script should fill up my ram with random stuff not just zeros.


More From » 13.04

 Answers
0

memtester is a user space program designed to allocate memory (any amount you specify) and test it with random patterns. It will avoid swap usage though. But if you take all memory away with memtester first (check with free -m) and then start anything else that uses a lot of memory (gimp, firefox, ...), that should get the swap going.



Another alternative would be something like openssl rand -base64 $((1024*1024*1024)) | less and in less use > to jump to the last line; this will cause 1GB of base64 encoded random data to be loaded in memory (but it's slow).



If you're looking for something more efficient, a small script in any scripting language (e.g. Python) might do.



#!/usr/bin/python2
import numpy
result = [numpy.random.bytes(1024*1024) for x in xrange(1024)]
print len(result)


That would allocate 1G of memory with random data and print the number of MB allocated before terminating. If you want more than 1024M, adapt the xrange value accordingly.


[#31004] Wednesday, February 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dileble

Total Points: 169
Total Questions: 105
Total Answers: 141

Location: Sao Tome and Principe
Member since Wed, Dec 29, 2021
2 Years ago
;