[Squeak] How to get the size of any object (sorry too long)

johnm at wdi.disney.com johnm at wdi.disney.com
Tue Nov 10 20:30:37 UTC 1998


(NISHIHARA Satoshi) wrote:
> Q1)
> byteSize of anObject is total of
>   object table entry size, 
>   object header size, 
>   instVarFieldSize, 
>   indexableFieldSize
> 
> byteSize:= bytesInOTE + objectHeadersSize + instVarFieldSize +
> indexableFieldSize.
> 
> mmm... Is this right?

Almost. Squeak doesn't have an object table, so no space for that. And
object headers can be 1, 2, or 3 words.

> case: right
> Q1.1)
> object table entry size is 8 bytes? or 12 bytes?

Zero bytes!

> Q1.2)
> If anObject is a instance of BlockContext, 
> must add the size of home method or not?

The home method context is a different object.

> Q1.3)
> aSmallInteger or aCharacter is immediate object.
> So consider as its bytesize = 0.
> Is this right?

Small integers are immediate. Characters are shared
references to one of a set of 256 Character objects.
String elements are, of course, a single byte, which
is used as an index into the 256 Character table.

> Q1.4)
> getting the byteSize of aMethod, must add methodHeaderSize (4 bytes)
> So its total is methodHeaderSize + bytesize of aMethod self + size of literals.
> Is this right?

I believe that the bytesize of a CompiledMethod includes the bytes for
object header and the literals.

	-- John





More information about the Squeak-dev mailing list