[R] R Memory Usage Concerns
hadley wickham
h.wickham at gmail.com
Tue Sep 15 06:41:25 CEST 2009
> I think this is just because you picked short strings. If the factor
> is mapping the string to a native integer type, the strings would have
> to be larger for you to notice:
>
>> object.size(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE))
> 8184 bytes
>> object.size(factor(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE)))
> 4560 bytes
No, it's probably because you have an older version of R, which
doesn't have the global string cache.
> object.size(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE))
4136 bytes
> object.size(factor(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE)))
4344 bytes
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list