How about asking the operating system, e.g.
### Method 1
## Setup
cmd <- paste("ps -o vsz", Sys.getpid())
## In your logging routine
z <- system(cmd, intern = TRUE)
cat("Virtual size: ", z[2], "\n", sep = "")
### Method 2
## Setup
file <- paste("/proc", Sys.getpid(), "stat", sep =
"/")
what <- vector("list", 44); what[[23]] <- integer(0)
## In your logging routine
vsz <- scan(file, what = what, quiet = TRUE)[[23]]/1024
cat("Virtual size: ", vsz, "\n", sep = "")
### Time the methods
library("rbenchmark")
benchmark(scan = scan(file, what = what, quiet = TRUE)[[23]]/1024,
system = system(cmd, intern = TRUE),
columns = c("test", "replications",
"elapsed", "relative"),
order = "relative")
# test replications elapsed relative
# 1 scan 100 0.015 1.0000
# 2 system 100 2.408 160.5333
The scan method should be plenty fast. Change as appropriate if your
definition of memory is different from virtual size.
Hope this helps a little.
Allan
On 06/08/10 19:11, Johann Hibschman wrote:> jim holtman<jholtman at gmail.com> writes:
>
>
>> ?memory.size
>>
> Only works on Windows. I guess I should have specified; this is on Linux.
>
> Thanks,
> Johann
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>