Loading...
 

Linux Memory

Memory faultscan occur due to various causes.

With Linux the memtester command which stress test to find memory subsystem faults can help diagnose an issue. memtester command is an effective userspace tester for stress-testing the memory subsystem. It is very effective at finding intermittent and non-deterministic faults under Linux.

You can run memtester as follows:

memtester MEMORYITERATIONS

Where,
> MEMORY: The amount of memory to allocate and test, in megabytes
> ITERATIONS: Number of loops to iterate through. Default is infinite

memtester’s exit code is 0 when everything works properly. Otherwise, it is the logical OR of the following values:

  • x01: Error allocating or locking memory, or invocation error
  • x02: Error during stuck address test
  • x04: Error during one of the other tests


Example

$ memtest 5 1
Output:

memtester version 4.0.5 (32-bit)
Copyright (C) 2005 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
pagesize is 4096
pagesizemask is 0xfffff000
want 5MB (5242880 bytes)
got 5MB (5242880 bytes), trying mlock ...locked.
Loop 1/1:
Stuck Address  : ok
Random Value  : ok
Compare XOR  : ok
Compare SUB  : ok
Compare MUL  : ok
Compare DIV  : ok
Compare OR  : ok
Compare AND  : ok
Sequential Increment: ok
Solid Bits  : ok
Block Sequential  : ok
Checkerboard  : ok
Bit Spread  : ok
Bit Flip  : ok
Walking Ones  : ok
Walking Zeroes  : ok
Done.
Display memtester’s exit code with following command (it is 0 when everything works properly):

$ echo $?

Memory resources

Linux utilises available memory for IO operation to get better performance from frequent requests to disk by caching and buffering requests

To clear cached memory run the following command

[gbrown@server ~]$ sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
[gbrown@server ~]$ sudo free -g
total       used       free     shared    buffers     cached
Mem:            31          0         31          0          0          0
-/+ buffers/cache:          0         31
Swap:            1          0          1                                                                                 
[gbrown@server ~]$