creek23 wrote:With regards to declaration, I actually declared it like this:
since it will be used across BAS files and ReDim'ed it from inside a function. Is that as good as
Shared?
~creek23
The array Bar() is so dynamic and it is not in the stack.
Remark:
Useful memory size of one element 'Bar(I)':
Sizeof(Foo) + Cast(Integer Ptr, @Bar(I).aaa)[2] = 56 + Cast(Integer Ptr, @Bar(I).aaa)[2] bytes
('Cast(Integer Ptr, @Bar(I).aaa)[2]' bytes being the useful memory size allocated for the string data, which is greater or equal to the string length)
('Cast(Integer Ptr, @Bar(I).aaa)[2]' being the third data of the array descriptor which is at '@Bar(I).aaa')
In case of non-nul string, one additional byte is allocated to the string data, corresponding to the non-useful terminal character 'Chr(0)'.
Code: Select all
Type Foo
aaa As String
bbb As Double
ccc As Integer
ddd As UInteger
eee As UInteger
fff As Integer
ggg As Integer
hhh As Integer
iii As Long
jjj As Integer
End Type
Print Sizeof(Foo)
Print
Print Offsetof(Foo, aaa)
Print Offsetof(Foo, bbb)
Print Offsetof(Foo, ccc)
Print Offsetof(Foo, ddd)
Print Offsetof(Foo, eee)
Print Offsetof(Foo, fff)
Print Offsetof(Foo, ggg)
Print Offsetof(Foo, hhh)
Print Offsetof(Foo, iii)
Print Offsetof(Foo, jjj)
Sleep