I need to handle massive (tens of millions) of MATLAB structs; I needed a dozen or so fields so I reckoned memory won't be an issue, until I discovered this ( explanation )
>> s=[];
>> s.first=1;
>> whos
Name Size Bytes Class Attributes
s 1x1 132 struct
>> s.second=2;
>> whos
Name Size Bytes Class Attributes
s 1x1 264 struct
>> s.third=3;
>> whos
Name Size Bytes Class Attributes
s 1x1 396 struct
Which obviously stops me from using tens of millions of much larger structs.
Resorting to classes solves the memory usage problem (a markup of 56 bytes per struct array) but it is prohibitively slower on the construction and in the destruction of objects.
How can I create stuct which is lightweight (like C structs) and fast?