Ok, the problem was that I was doing: usedMemory := usedMemory + self internalByteSize: oop.
that didn't work and always answered me the same number. Now, I had to do this: usedMemory := usedMemory + (self internalByteSize: oop). I don't understand why. Thanks Mariano On Thu, Apr 29, 2010 at 3:22 PM, Mariano Martinez Peck < [email protected]> wrote: > > > >> It's close but not entirely correct. The computation needs to include the >> extra header word for "large" instances (> 255 bytes). Squeak has three >> possible header sizes: >> >> 1 header word - used by compact classes >> 2 header words - used by regular classes >> 3 header words - used by "large" instances >> >> BTW, SpaceTally>>spaceForInstancesOf:withInstanceCount: has the correct >> computation (except for 64 bit :-) >> >> > Ok, perfect. Thanks :) > > > >> >> Is there a way to know this >>> but from the VM side also ? how ? >>> I really need it from the VM side :( but I have no idea how to do it. >>> >> >> It's easy to do in the VM, just use this: >> >> primitiveByteSize >> "Answers the number of bytes the receiver occupies" >> >> | nbytes| >> self export: true. >> oop := self popStack. >> nbytes := (self sizeBitsOf: oop) + (self extraHeaderBytes: oop). >> self pushInteger: nbytes. >> >> > > I tried this and seems to work ok. I don't really need a primitive but an > internal method that is called by a primitive. So, I did something like > this: > > internalByteSize: anOop > > "Answers the number of bytes the receiver occupies" > | nbytes| > self inline: true. > nbytes := (self sizeBitsOf: anOop) + (self extraHeaderBytes: anOop). > ^ nbytes. > > > > and then I call it like this for example: > > oop := self firstAccessibleObject. > [oop = nil] whileFalse: [ > (self isIntegerObject: oop) > ifFalse: [ > size := self internalByteSize: oop. > ......] > oop := self accessibleObjectAfter: oop. > ]. > > > but internalByteSize ALWAYS return me the same value...do you know what can > be wrong ? > > Thanks in advance > > Mariano > > >
_______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
