Hi guys, I haven't checked if this bug exists already, so please ignore this if it's been reported before.
Bug in WAMemoryItem: sizeOfObject: anObject | headerSize instanceSize variableSize | headerSize := anObject class indexIfCompact > 0 ifTrue: [ 4 ] ifFalse: [ 8 ]. instanceSize := anObject class instSize. variableSize := anObject class isBytes ifTrue: [ anObject basicSize ] ifFalse: [ anObject class isWords ifTrue: [ Smalltalk wordSize * anObject basicSize ] ifFalse: [ Smalltalk wordSize * anObject basicSize // 2 ] ]. ^ headerSize + instanceSize + variableSize In this snippet, the units that are added together in the last line are of different units. instanceSize is in unit "number of machine words", whereas variableSize and headerSize are in unit "bytes". The method is fixed here: sizeOfObject: anObject | headerSize instanceSize variableSize | headerSize := anObject class indexIfCompact > 0 ifTrue: [ 4 ] ifFalse: [ 8 ]. instanceSize := anObject class instSize * Smalltalk wordSize. variableSize := anObject class isBytes ifTrue: [ anObject basicSize ] ifFalse: [ anObject class isWords ifTrue: [ Smalltalk wordSize * anObject basicSize ] ifFalse: [ Smalltalk wordSize * anObject basicSize // 2 ] ]. ^ headerSize + instanceSize + variableSize Example: |m| dict := Dictionary new. m := WAMemory new. dict traverseWithMemory: m seen: IdentitySet new. m totalSize This will incorrectly spit out 10, but should return 16, on a 32 bit VM. Niko -- http://scg.unibe.ch/staff/Schwarz twitter.com/nes1983 Tel: +41786126354