Memory required for struct array
Show older comments
it seems to me the numbers derived by Walter are not correct.
In this thread I attempt to fix, mostly by reverse engineering. Note that this are not documented and possibly depend . on the MATLAB version. Currently it's R2023a.
So there is no question explicitly formulated here
Answers (1)
Bruno Luong
on 22 Aug 2023
Edited: Bruno Luong
on 22 Aug 2023
4 Comments
Bruno Luong
on 22 Aug 2023
clear s
s(100).foo = [];
whos s
clear s
s(99).foo = [];
whos s
960 - 952
so the number of extra bytes for each numel() must be 8, not 16.
Bruno Luong
on 22 Aug 2023
Walter Roberson
on 22 Aug 2023
At the moment, I do not immediately see a difference between your size predictions and my previous enumeration?
My discussion was slightly sloppy in taking about sizes for additional entries, under the assumption that at least one entry was assigned to for each fieldname; it probably would have been better to rewrite them to a base of no entries written to. On the other hand, when no entries at all are allocated to a field, it looks like the 8-bytes-per-element pointer table is not allocated at all.
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!