I created bagged tree model method = "treebag"
using the caret package in R and the resulting model size is 12 Mb when viewing in R-Studio. But when I save to disk for later use with save()
the size on disk increases to 151 Mb! Using different compression schemes brings the size down a bit but all are still way larger than in memory. Anyone successfully dealt with this problem?
The likely reason is that the enclosing environment associated with objects is not considered in the results of object.size(), but is written to disk when saved. Use the pryr::object_size() function to see the object size with environment included. More explanation can be found at: http://adv-r.had.co.nz/memory.html#object-size
> object.size(m1)
16200200 bytes
> pryr::object_size(m1)
215 MB
> save(m1, file="m1.rda")
> file.info("m1.rda")$size
[1] 219475772
There also has been some discussion of this issue in another question: object.size() reports smaller size than .Rdata file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With