From thomasio at cs.tu-berlin.de  Sat Aug  7 15:14:10 2004
From: thomasio at cs.tu-berlin.de (Thomas =?iso-8859-1?q?K=F6nig?=)
Date: Sat Aug  7 15:11:02 2004
Subject: [Rd] memory usage of S4 methods
Message-ID: <200408071514.10998.thomasio@cs.tu-berlin.de>

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


[Rd] memory usage of S4 methods
Thomas =?iso-8859-1?q?K=F6nig?=