What is the “real” memory size occupied by a static array?
This question has a relation with my previous question, What is the “real” memory size occupied by a dynamic array?
Example:
var
AText: array [0..6] of AnsiChar;
Question
What is the real size of A开发者_如何转开发Text occupied in memory? Is it really 7 bytes?
Yes it is really 7 bytes
I think so. Maybe D2010+ adds some reference to the RTTI record.
Then there is also alignment, the next variable/field might not start directly after this variable/field leaving some slack bytes. (typically round up to some power of 2 like 16)
Note that alignment might be different for a local and a global variable, class var etc. The various segments all can have different alignment rules, and if it is a field/class var it might be different still.
精彩评论