# NOT RUN {
# obj_size correctly accounts for shared references
x <- runif(1e4)
obj_size(x)
z <- list(a = x, b = x, c = x)
obj_size(z)
# this means that object size is not transitive
obj_size(x)
obj_size(z)
obj_size(x, z)
# use obj_size() to see the unique contribution of each component
obj_sizes(x, z)
obj_sizes(z, x)
obj_sizes(!!!z)
# obj_size() also includes the size of environments
f <- function() {
x <- 1:1e4
a ~ b
}
obj_size(f())
#' # In R 3.5 and greater, `:` creates a special "ALTREP" object that only
# stores the first and last elements. This will make some vectors much
# smaller than you'd otherwise expect
obj_size(1:1e6)
# }
Run the code above in your browser using DataLab