
Memtst package
--------------

This simple memory testing program was written to test sparcstation 2
memory. The problem was that the sun diagnostics (sundiag) would always
pass even if it was left running for several days, though some memory
hungry applications that we were working on would crash with memory parity
errors. The only difference that I could see between the application and
the sundiags was that the sundiag memory tester did not write into memory.
The whole package consists of 1 C program and 2 shell scripts.

The C Program (memtst)
----------------------

The binary (the compiled version of memtst.c) is what does the
testing. It allocates (malloc(3)) all the memory that it can up to the
maximum specified.  The amount of memory that you want tested may be
specified as the first argument (eg. memtst 16 -- tests 16MB of memory)
or memtst will prompt you for it at run time as in:

# memtst
How many MEGS of memory do you want to test? 16
Testing 16MB or 16777216 bytes of virtual memory with 4 patterns
  Pattern       Pass
  FFFFFFFF       1

Memtst has two different output formats which depend on what the standard
output is. If stdout is to a terminal (isatty(3)) memtst will update the
screen every sub-pass.  (as shown above). If output is to a pipe or a file
(not a tty) memtst reports after every 10 full passes. A full pass is completed
when all of the test patterns have been used. You may change or add to the
number of patterns by editing memtst.c.

Compile memtst with "cc -O -o memtst memtst.c" or use the Makefile.

The Scripts
-----------

The two shell scripts were written to start and stop memtst from cron.
memtst-start starts up memtst. It saves the PID in a file for memtst-stop.
It takes a single numeric argument which is the number of megabytes that you
want to test. If no value is supplied 16MB is used.

Memtst-stop stops memtst and mails a report (be it good or bad) to someone.
memtst-stop takes a single argument which is the email address of the
individual to send the report to, with no argument it is sent to root.
It always greps the error log files (/var/adm/messages*) if an error is
suspected and mails this too. Memtst-stop suspects a crash if the PID
file does not exist because the PID file is kept on /tmp which is usually
cleared at startup. 

Example crontab entries
-----------------------

Test 64MB starting at 10:00 PM every day and stopping at 6:00 AM every
morning. Output is sent to "person@host.subdom.domain".

00 22 * * * /usr/local/src/memtst/memtst-start 64
00 06 * * * /usr/local/src/memtst/memtst-stop person@host.subdom.domain


Finally
-------

Memtst is a real memory hog and may cause some noticeable drop in performance.
If you start up memtst on all of your systems available virtual memory
you might lock out all other processes (not enough memory to fork!), plus
your system will start paging itself to death. A good rule of thumb is
to start up memtst on the amount of physical memory minus 7MB. This will
usually prevent paging and will allow openwindows or sunview some breathing
space. On the other hand if you want to test your swap/paging mechanism
(or see a Sparcstation really sweat) bump the value up to the maximum
virtual adress space of your system.


Written by P. Blanchfield (phil@dgbt.doc.ca) at The Communications Research
Centre, Ottawa.  June 1991.
