[R] Object size in bytes

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Sep 1 22:28:14 CEST 2000


Prof Brian D Ripley <ripley at stats.ox.ac.uk> writes:

> Isn't this going to fail in 1.2.0?  Not only is the workspace size
> not fixed, but also the garbage collector does not clean out in one pass.
> (And the size of Ncells changes with that version.)

It's probably not going to be reliable, no.

> Also, to what extent does R share parts of objects (e.g. lists) without
> copying them?  (S does quite extensively.)

R does it extensively during function evaluation, but I think that as
soon as an object has a name it is generally distinct from other named
objects unless .Alias trickery is in play. (That may not be cast in
stone since it may be more efficient to do otherwise, but if e.g. x
and y share a names attribute and you do names(x)[3]<-foo, then the
names(y) should be unchanged, which is rather difficult to ensure)

> I would have thought one reasonable approximate answer was to dump the
> object in binary save format and look at the file size.

Good idea if it works. I forget whether all things are really the same
size in memory and on disk. 

Might be easier just to write the code for summing up the byte sizes... 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list