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).