[R] Object size in bytes
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Sep 1 12:04:48 CEST 2000
Nicholas Lewin-Koh <kohnicho at comp.nus.edu.sg> writes:
> Hi,
> Is there a command that will give the total size of an R object in bytes?
No. You can get some of the way with
function (it)
{
x1 <- gc()[, 1]
copy <- it
x2 <- gc()[, 1]
x1 - x2 - c(5, 6) # correct for variables and function call (fudged)
}
> x<-rnorm(20000)
> sizeit(x)
Ncells Vcells
1 20000
> names(x)<-1:20000
> sizeit(x)
Ncells Vcells
3 30001
And from there on things become system dependent. On x386 (Linux and
also Windows IIRC) an Ncell is 20 bytes and a Vcell is 8.
Oddly enough, this doesn't seem to work for functions, and I haven't
got a clue why at the moment:
> sizeit(glm.fit)
Ncells Vcells
1 -1
--
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