Reputation:
require(lobstr)
x <- lapply(1:50, function(i) c(rep("abc", i)))
obj_size(x) ## 13,352 B
sum(sapply(x, obj_size)) + 50*8 + 56 ## 16104 B 8 is pointer size, 56 is initial space
why the results are different?
thanks
Upvotes: 0
Views: 91
Reputation: 654
I did try to replicate your problem with base R object.size function,
x <- lapply(1:50, function(i) c(rep("abc", i)))
object.size(x)
sum(sapply(x, object.size)) + 50*8 + 56
I found below result. there does not seems to be much of a difference here might be 8 bytes here and there but it's nearly the same. I don't think it would make any significant difference in with such a small difference.
Upvotes: 0