I'm trying to use Memtester as a memory stress and correctness test for my organization's Linux boxes. Memtester basically just takes in an amount of memory to test as an argument, locks that much memory using memlock()
, and then runs a number of patterns to verify that the memory is good.
Since I'm trying to verify correctness, I want to be testing as much of the machine's memory as possible. I've been trying to do this by passing it MemFree from /proc/meminfo. Or rather, I have a script that spawns multiple processes, each asking for MemFree (see below), because the OS doesn't allow a single process to lock more than 50% of memory.
The problem is, if I lock more than ~90% of memory, my computer locks up, presumably due to thrashing. About 30 minutes later I'm finally able to use it again.
Is there a way, programmatically or otherwise, to find out how much memory I can lock before it starts swapping?
I want this to run on any Linux box, so anything that requires me to change the system configuration is a no-go. Also, you can assume that the test will be the only thing running on the system (besides normal OS stuff, of course), since the machines are supposed to be left alone while we're stress testing them.
part of the script that spawns memtester processes
while [ $MEMAVAILABLE -ge 0 ]
do
./memtester $MEMAVAILABLE'K' &
sleep 10 #wait for previous process to lock its memory
MEMFREE=`cat /proc/meminfo | grep "MemFree" | sed 's/MemFree:\(\s\)*\(.*\) kB/\2/g'`
MEMAVAILABLE=$(($MEMFREE-($MEMTOTAL*5/100)))
done
wait
.