I’m not sure if this will help or hurt…
mutable struct Bar
Bar() = new(0, 0, 0)
bar = Bar()
print("sizeof(bar) = $(sizeof(bar))\n")
print("summarysize(bar) = $(summarysize(bar))\n")
Foo() = new(0, nothing)
Foo(a, b) = new(a, b)
foo = Foo()
print("sizeof(foo) = $(sizeof(foo))\n")
print("summarysize(foo) = $(summarysize(foo))\n")
foo2 = Foo(0, Bar())
print("sizeof(foo2) = $(sizeof(foo2))\n")
print("summarysize(foo2) = $(summarysize(foo2))\n")
Processes the following output:
sizeof(bar) = 24
summarysize(bar) = 24
sizeof(foo) = 16
summarysize(foo) = 16
sizeof(foo2) = 16
summarysize(foo2) = 40
Bar is 24 bytes, three 8 byte values for a total of 24 bytes, both sizeof and summarysize report the same amount.
Foo can have a child Bar or it could have nothing,
foo is it without a Bar, and
foo2 is with a Bar. You will notice that
sizeof(foo) == sizeof(foo2). The amount of bytes that structure needs is 16 bytes of allocated space whether Bar is there or not. When Foo HAS a bar then summarysize reports 40 bytes which is 16 bytes for Foo and 24 bytes for Bar.
summarysize is recursive looking at any child objects and adding their bytes to the total.
Does that make a little more sense? The sizeof an Array of Arrays is the amount of memory need to reference all the child arrays. The summarysize includes the sizes of the referenced arrays.