Astaroth
Astaroth

Reputation: 2291

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 AText occupied in memory? Is it really 7 bytes?

Upvotes: 5

Views: 297

Answers (2)

Marco van de Voort
Marco van de Voort

Reputation: 26356

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.

Upvotes: 1

Lars Truijens
Lars Truijens

Reputation: 43595

Yes it is really 7 bytes

Upvotes: 2

Related Questions