[Rd] 'methods' and environments.
laurent at cbs.dtu.dk
Mon Jun 2 06:57:34 MEST 2003
I have quite some trouble with the package methods.
"Environments" in R are a convenient way to emulate
pointers (and avoid copies of large objects, or of
large collections of objects). So far, so good,
but the package methods is becoming more (and more)
problematic to work with. Up to version R-1.7.0,
slots that were environments were still references
to an environment, but I discovered in a recent
R-patched that this is not the case any longer:
environments as slots are now copied (increasing
the memory consumption by more than three fold in my case).
The (excessive) duplication (as a simple example
shown below demonstrates it) is now enforced
(as environments are copied too) !!!
> m <- matrix(0, 600^2, 50)
## RSS of the R process is about 150MB
> rm(m); gc()
used (Mb) gc trigger (Mb)
Ncells 364813 9.8 667722 17.9
Vcells 85605 0.7 14858185 113.4
## RSS is now about 15 MB
> setClass("A", representation(a="matrix"))
> a <- new("A", a=matrix(0, 600^2, 50))
## The RSS will peak to 705 MB !!!!!!
Are there any plans to make "methods" usable with
large datasets ?
More information about the R-devel