On Sat, 7 Aug 2004, Thomas K?nig wrote:
> 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?
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.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595