[Rd] memory usage of S4 methods

From: Thomas König <thomasio_at_cs.tu-berlin.de>
Date: Sat 07 Aug 2004 - 23:14:10 EST


Hi,

I have some problems with the memory usage of S4-generics. For example, I observed the following behaviour:
> gc()

         used (Mb) gc trigger (Mb)
Ncells 432091 11.6     531268 14.2
Vcells 116052  0.9     786432  6.0

> setClass("A",representation(x="numeric"));
[1] "A"
> setClass("B",representation(x="numeric"));
[1] "B"
> f.default <- function(a,b,c,d,e,f,g,h,i,j,k,l,m)
+ {
+   res <- standardGeneric("f");
+   return(res);
+ }

> f.A <- function(a)
+ {
+   print("f.A");
+   return(0);
+ }

> f.AB <- function(a,b)
+ {
+   print("f.B");
+   return(0);
+ }

> setGeneric("f",f.default)

[1] "f"
>

setMethod("f",signature=signature("A","B","missing","missing","missing","missing","missing","missing","missing","missing","missing","missing","missing"),f.AB); [1] "f"
>

setMethod("f",signature=signature("A","missing","missing","missing","missing","missing","missing","missing","missing","missing","missing","missing","missing"),f.A); [1] "f"
> gc()

          used (Mb) gc trigger (Mb)
Ncells 1579264 42.2 3708127 99.1
Vcells 1558026 11.9 4232140 32.3
> R.version

         _
platform i686-pc-linux-gnu

arch     i686
os       linux-gnu

system i686, linux-gnu
status alpha
major 1
minor 9.1
year 2004
month 05
day 25
language R

More than 100 MB for 2 classes and 2 generics? Is this correct?

Greetings,

Thomas König



R-devel@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel Received on Sat Aug 07 23:13:42 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 08:59:17 EST