Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Size of a Class Object 1

Status
Not open for further replies.

secureshell

Programmer
Sep 24, 2002
22
0
0
CA

Hi,

I have read the "Data Type Summary" topic in MSDN and this is what they have to say about Object and User-defined data types:

Data type | Storange | Range
Object | 4 bytes | Any Object reference
User-defined (using Type) | Number required by elements | The range of each element is the same as the range of its data type

I want to know how to find the actual size of a class object in runtime (or design time). Besides the variables declared in the class, the class has quite a few member routines and functions. Does this contribute to the runtime size of the class? Thx. {W r i t e C o d e A n d K i c k A s s}
 
As the "Data Type Summary" points out, the size of an object variable is always 4 bytes for a 32-bit program.

The actual size of the object being referenced shouldn't be important. Because object's aren't stored on the stack, the only limitation on its size is the amount of memory Windows is willing to provide - which, with virtual memory, can be far more than the amount of RAM on the machine.

The fact that an object reference is 4 bytes may be important if you use lots of recursive algorithms, because this data is stored on the stack.
 
I see. Thx, that should provide me with what I was looking for. {W r i t e C o d e A n d K i c k A s s}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top