2010/9/21 Mariano Martinez Peck <marianopeck@gmail.com>
On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen < henrik.s.johansen@veloxit.no> wrote:
On 21.09.2010 19:10, Mariano Martinez Peck wrote:
Hi folks. I wasn't aware of the class SparseLargeTable but it seems it has two important instances "SparseLargeTable allInstances size -> 2"
They are the class side variables #DecimalProperty and #GeneralCategory in Unicode.
Actually,
(Unicode classPool at: 'GeneralCategory') size -> 917632
(Unicode classPool at: 'DecimalProperty') size -> 917632
So...collections of almost 1 million elements.
Now a couple of questions:
1) Is this normal/expected? In my calculus both arrays are like 3mb of memory
Look at the implementation, there's a reason they're called sparse. If my math is correct (crosses fingers), DecimalProperty is ~15KB, GeneralCategory ~70KB
So...there must be a problem with my code, I was doing something like SpaceTally does:
spaceForUsedInstancesOf: aClass withInstanceCount: instCount "Answer the number of bytes consumed by all instances of the given class, including their object headers."
| isCompact instVarBytes bytesPerElement headerBytes total | instCount = 0 ifTrue: [^ 0]. isCompact := aClass indexIfCompact > 0. instVarBytes := aClass instSize * 4. aClass isVariable ifTrue: [ bytesPerElement := aClass isBytes ifTrue: [1] ifFalse: [4]. total := 0. aClass allInstancesDo: [:inst | | contentBytes | contentBytes := instVarBytes + (inst size * bytesPerElement). headerBytes := contentBytes > 255 ifTrue: [12] ifFalse: [isCompact ifTrue: [4] ifFalse: [8]]. (UnusedObjectDiscoverer current primitiveGetUsedBit: inst) ifTrue: [total := total + headerBytes + contentBytes]]. ^ total] ifFalse: [ headerBytes := instVarBytes > 255 ifTrue: [12] ifFalse: [isCompact ifTrue: [4] ifFalse: [8]]. ^ instCount * (headerBytes + instVarBytes)].
SparseLargeTable instanceCount ->>> 2
SpaceTally new spaceForUsedInstancesOf: SparseLargeTable withInstanceCount: 2 ->>> 7341112
You must use basicSize not size. This is a sparse table. It has a virtual size. size answers that virtual size, not the actual size. If you use basicSize you'll also need to traverse su structure to correctly compute the size of the entire sparse array including its pages. HTH Eliot
thanks
2) If I don't use UTF and I send an encoding as parameter in the VM (different from UTF), do I need this class side variables?
What Lukas said.
Cheers, Henry
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project