Q:

Memory size of logical variable

I'm working on a large data.frame (e.g. 500k rows/observations, 2500 columns/features). Every feature is Boolean, so only two values are possible TRUE / FALSE.
After noticing a extremely high RAM usage I checked the following:
myVar = TRUE
class(myVar)
# [1] "logical"
object.size(myVar)
# 48 bytes

I'm used to char-sized bools from C taking 8Bit = 1Byte. Can someone  elaborate where this massive overhead comes from or am I doing something wrong?

A:

Compare below:
object.size(logical())
# 48 bytes

object.size(TRUE)
# 40 bytes

See post by Hadley about Memory for more info.

Every length 0 vector occupies 40 bytes of memory.

