next up previous contents
Next: The Virtual Method Table Up: Objects Previous: Constructor and Destructor calls

Memory storage of objects

  Objects are stored in memory just as ordinary records with an extra field : a pointer to the Virtual Method Table (VMT). This field is stored first, and all fields in the object are stored in the order they are declared. This field is initialized by the call to the object's Constructor method.

If the object you defined has no virtual methods, then a nil is stored in the VMT pointer. This ensures that the size of objects is equal, whether they have virtual methods ore not.

The memory allocated looks as in table (5.1).

  

Offset What
+0 Pointer to VMT.
+4 Data. All fields in the order the've been declared.
...
Table 5.1: Object memory layout



Michael Van Canneyt
Thu Sep 10 14:04:11 CEST 1998