<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
<br></div>
It&#39;s close but not entirely correct. The computation needs to include the extra header word for &quot;large&quot; instances (&gt; 255 bytes). Squeak has three possible header sizes:<br>
<br>
        1 header word  - used by compact classes<br>
        2 header words - used by regular classes<br>
        3 header words - used by &quot;large&quot; instances<br>
<br>
BTW, SpaceTally&gt;&gt;spaceForInstancesOf:withInstanceCount: has the correct computation (except for 64 bit :-)<div><br></div></blockquote><div><br>Ok, perfect. Thanks :)<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Is there a way to know this<br>
but from the VM side also ? how ?<br>
I really need it from the VM side :(  but I have no idea how to do it.<br>
</blockquote>
<br></div>
It&#39;s easy to do in the VM, just use this:<br>
<br>
primitiveByteSize<br>
        &quot;Answers the number of bytes the receiver occupies&quot;<br>
<br>
        | nbytes|<br>
        self export: true.<br>
        oop := self popStack.<br>
        nbytes := (self sizeBitsOf: oop) + (self extraHeaderBytes: oop).<br>
        self pushInteger: nbytes.<br>
<br>
</blockquote><div><br><br>I tried this and seems to work ok. I don&#39;t really need a primitive but an internal method that is called by a primitive. So, I did something like this:<br><br>internalByteSize: anOop<br>       &quot;Answers the number of bytes the receiver occupies&quot;<br>
       | nbytes|<br>       self inline: true.<br>       nbytes := (self sizeBitsOf: anOop) + (self extraHeaderBytes: anOop).<br>       ^ nbytes.<br><br><br><br>and then I call it like this for example:<br><br>oop := self firstAccessibleObject.<br>
    [oop = nil] whileFalse: [<br>        (self isIntegerObject:  oop)<br>            ifFalse: [ <br>                size :=  self internalByteSize: oop. <br>           ......]<br>  oop := self accessibleObjectAfter: oop.<br>
    ].<br><br> <br>but internalByteSize ALWAYS return me the same value...do you know what can be wrong ?<br><br>Thanks in advance<br><br>Mariano<br><br></div></div><br>