18 setembro, 2021
object.size()
lobstr::obj_size()
x <- "ben" lobstr::obj_size(x) ## 112 B object.size(x) ## 112 bytes y <- rep(x, 1000); head(y) ## [1] "ben" "ben" "ben" "ben" "ben" "ben" lobstr::obj_size(y) ## 8,104 B object.size(y) ## 8104 bytes
# Objeto lista l1 <- list(median, range) # Quanto de memoria? lobstr::obj_size(l1)
## 1,360 B
# Inspecionando as funcoes 'median' e 'range' .Internal(inspect(median)) ## @0x0000000006463210 03 CLOSXP g0c0 [MARK,REF(3)] ## ... .Internal(inspect(range)) ## @0x0000000000368688 08 BUILTINSXP g0c0 [MARK,REF(65535)] # Inspecionando o objeto 'l1' l1 <- list(median, range) .Internal(inspect(l1)) ## @0x000000000038f300 19 VECSXP g0c2 [REF(1)] (len=2, tl=0) ## @0x0000000006463210 03 CLOSXP g0c0 [MARK,REF(4)] ## ... ## @0x0000000000368688 08 BUILTINSXP g0c0 [MARK,REF(65535)]
:
> # Tamanho de memoria dos objetos > lobstr::obj_size(1:10) ## 680 B > lobstr::obj_size(1:10000) ## 680 B > lobstr::obj_size(1:1000000) ## 680 B > lobstr::obj_size(c(1:10)) ## 96 B > lobstr::obj_size(c(1:10000)) ## 40,048 B > lobstr::obj_size(c(1:1000000)) ## 4,000,048 B