Induce swapping on Solaris

I'm testing a load monitoring script and I need to induce swapping so that the scan rate rises significantly. But I'd prefer not to crash the box completely. Anyone have a one liner or short shell script?

Thanks.

cp has a good history of inducing memory pressure. Given sufficient system disk space, insufficient RAM, etc and several large concurrent file copies this can quickly cause a system to start swapping.

Another option is to mmap() (n) large files to the point where the system starts swapping (which is the behavior of some popular cp's anyway...). There were a couple decent google hits on 'cp and mmap'.

All of this could effect system stability. You'd have to be very careful with your test case.

Try that one, it should reasonably induce swapping.
Quit with control-C

#!/bin/ksh
trap 'rm -f /tmp/foo*;exit' 2 0
while true
do
  mkfile $(vmstat 1 2 | tail -1|nawk '{print $5}')k /tmp/foo$RANDOM
  sleep 10
  swap -s || exit
done