[R] Determining if swap memory is turned off
Prof. John C Nash
nashjc at uottawa.ca
Fri Jun 26 17:48:58 CEST 2009
In order to run some performance tests on optimization tools, I want to
be able
to avoid the use of swap memory. In *nix systems, at least Linux ones, I
can issue
a 'sudo swapoff -a' command and use just the RAM available. If I don't
do this, at
some point swap will be used, the disk goes ballistic and the machine is
unresponsive
because it is thrashing data to the swap. I suspect others have
encountered this
too. Clearly I'd rather fail out than get into the thrashing situation.
Generally I
prefer no swap -- memory is cheap enough that it is easier not to worry
about these
sorts of woes. However, I'd like to make packages I'm developing
bullet-proof.
What I need to know is if there are similar facilities on other
platforms and how to
use them. I see memory.size and memory.limit for Windows -- making R
less platform
independent -- and they seem to work on a WinXP virtual machine I have
available.
However, I suspect that the memory.limit includes the swap. When I was
running
Windoze, I tried valiantly to get the PageFile.sys killed and found it
kept being set
up again despite following all the recommended steps. (I needed to avoid
the
plaintext of an encrypted file being "saved" for me!) I know nothing
about Mac
swap and how to control it.
Advice welcome. Below is a crude but self-contained example.
John Nash
## memcrash.R -- try to hit the wall with memory
cat("memcrash.R -- try to hit the wall\n")
cat("You should have swap turned off\n")
temp<-readline("Do you?")
if (temp != "y") stop("Fix swap")
for (j in 1:10) {
n <- 5^j
cat("building matrix of order ",n,"\n")
A<-matrix(nrow=n, ncol=n)
} # end loop
More information about the R-help
mailing list