Skip to content

memory usage of S4 methods

2 messages · Thomas Koenig, Brian Ripley

#
Hi,

I have some problems with the memory usage of S4-generics. For example, I 
observed the following behaviour:
used (Mb) gc trigger (Mb)
Ncells 432091 11.6     531268 14.2
Vcells 116052  0.9     786432  6.0
[1] "A"
[1] "B"
+ {
+   res <- standardGeneric("f");
+   return(res);
+ }
+ {
+   print("f.A");
+   return(0);
+ }
+ {
+   print("f.B");
+   return(0);
+ }
[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"
used (Mb) gc trigger (Mb)
Ncells 1579264 42.2    3708127 99.1
Vcells 1558026 11.9    4232140 32.3
_
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
#
On Sat, 7 Aug 2004, Thomas K?nig wrote:

            
No:  you are not reading gc() output correctly.  Please read its help
page, or even the output (`used' is what is used).

Please do not send reports on alpha pre-releases of released versions:
see the posting guide.  No one will have that version to hand to check 
what you are doing.  (I might have checked the released version if you 
had provided code that could be pasted in, but you made it unnecessarily 
hard, including using lines that the MUA has to break.)

The issue appears to be your attempt to set methods on a very long list of 
arguments.  What practical use is that?  I think you probably only want to 
set them on two arguments.