# NOT RUN {
library(utils)
foo <- new.env()
foo$b <- 1:10
foo$d <- 1:10
objSize(foo) # all the elements in the environment
object.size(foo) # different - only measuring the environment as an object
object.size(prepInputs) # only the function, without its enclosing environment
objSize(prepInputs) # the function, plus its enclosing environment
# Size of all packages; includes their imported functions
# }
# NOT RUN {
bar <- objSizeSession(1)
print(bar, units = "auto")
# }
# NOT RUN {
os1 <- object.size(as.environment("package:reproducible"))
os2 <- objSize(as.environment("package:reproducible"))
(os1) # very small -- just the environment container
sum(unlist(os2)) # around 13 MB, with all functions, objects
# and imported functions
# }
Run the code above in your browser using DataLab