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

Dan Ingalls DanI at wdi.disney.com
Mon Nov 9 22:21:34 UTC 1998


NISHIHARA Satoshi wrote...

>byteSize:= bytesInOTE + objectHeadersSize + instVarFieldSize +
>indexableFieldSize.
>
>mmm... Is this right?

Yes.  Except...

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

Zero.  Squeak does not have an object table.

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

No.  Contexts and BlockContexts point to the home method rather than copying it.

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

Not quite.  SmallIntegers are immediate.  Characters are not, but there are only 256 of them which are shared, so their space is effectively 0. 

>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?

No.  The response to size is the size in bytes, including the literal frame and the 4-byte sourcecode pointer at the end.  Just add 4 for the method header.

Hope this helps.

	- Dan





More information about the Squeak-dev mailing list