I am using an array of a type that I define, but this seems to take bigger memory than I have thought.
For example, if I check the memory allocated to ‘a = Int8[1,1,1]’, ‘Base.summarysize(a)’ gives 3 as expected.
But then I define a “test1” type by
type test1 val::Int8 end
and then check the memory allocated to
b = test1[test1(1), test1(1), test1(1)],
Base.summarysize(b) gives 27, which on average costs 9 = 1+8 per element.
Moreover, If I use multiple types as follows:
type test2 a::Int64 b::Float64 c::Bool end
Base.summarysize(test2(1,1.0,true)) gives 24, not
Base.summarysize(1) + Base.summarysize(1.0) + Base.summarysize(true) = 17.
I am curious if this is a generic feature of Julia, or there is a way to fix this issue.