Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What data does a TObject contain?

TObject.InstanceSize returns 8, yet TObject doesn't declare any data members. According to the implementation of TObject.ClassType, the first 4 bytes can be explained as a pointer to the object's TClass metadata. Anyone know what the other 4 bytes of overhead are there for?

EDIT: Apparently this is specific to D2009. In older versions, it's only 4 bytes.

like image 720
Mason Wheeler Avatar asked Mar 24 '09 20:03

Mason Wheeler


People also ask

What is an object data?

A data object is a region of storage that contains a value or group of values. Each value can be accessed using its identifier or a more complex expression that refers to the object. In addition, each object has a unique data type.

What represents data value of an object?

Data object is usually represented as storage in Computer memory and a data value is represented by a pattern of bits.

What is a data object in C?

Data object is a general term for a region of data storage that can be used to hold values. The C standard uses just the term object for this concept. One way to identify an object is by using the name of a variable.


1 Answers

In Delphi 2009, there is the ability to have a reference to a synchronization monitor. See:

class function TMonitor.GetFieldAddress(AObject: TObject): PPMonitor;
class function TMonitor.GetMonitor(AObject: TObject): PMonitor;

...in System.pas

Also, there is still a pointer to the VMT. (Virtual Method Table.) From Delphi in a Nutshell:

The TObject class declares several methods and one special, hidden field to store a reference to the object's class. This hidden field points to the class's virtual method table (VMT). Every class has a unique VMT and all objects of that class share the class's VMT.

like image 134
Craig Stuntz Avatar answered Sep 20 '22 04:09

Craig Stuntz