Reputation: 805
julia> type TestA
a::Int32
b::Int64
end
julia> type TestB
a::Int64
b::Int64
end
julia> sizeof(TestA),sizeof(TestB)
(16,16)
I am expeced that sizeof(TestA)
will be 4+8=12.
I am curious about the principle behind the scenes.
Why TestA
and TestB
have the same size?
ps: http://docs.julialang.org/en/latest/devdocs/object/ is a good material
Upvotes: 3
Views: 519
Reputation: 16331
Byte alignment is the answer. The documentation states that:
Note that all objects are allocated in multiples of 4 bytes and aligned to the platform pointer size.
Upvotes: 8