Here's the code I used to confirm Henrik's math:

table := Unicode classPool at: 'GeneralCategory'.
count := table basicSize.
1 to: table basicSize do: [ :i |
        (table basicAt: i) isNil ifFalse: [
                count := count + (table basicAt: i) basicSize ] ].
(count / 1024) asFloat

-> 66.8759765625

+ the headers of each subtable.

Cheers,
Adrian

On Sep 21, 2010, at 20:16 , Henrik Sperre Johansen wrote:

> On 21.09.2010 20:07, Mariano Martinez Peck wrote:
>> 
>> 
>> On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen 
>> <[email protected] <mailto:[email protected]>> 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).
> There you go. Use basicSize, size is overridden by f.ex. HashedCollections 
> and LargeSparseTables.
> 
> Cheers,
> Henry
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to