On Thu, Apr 29, 2010 at 6:00 PM, Andreas Raab <[email protected]> wrote:

> On 4/29/2010 6:22 AM, Mariano Martinez Peck wrote:
>
>> 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.
>>     ].
>>
>
> Do you realize that this simple computes the used memory which is
> information that's directly accessible via the vm parameters? I don't recall
> which one but you might want to look at these to see if they already have
> what you need.
>

Thanks Andreas. I guess I should have explained my situation. Basically,
what I was trying to do (and I did at the end) is to use the last free bit
of the object header to use it to detect used and unused objects. I modified
the VM so that when an object receives a message, it enables such bit. I
also have primitives to mark and unmark all objects.

I am not sure what I will do then with the unused objects, but for the
moment, I just wanted to get numbers. Statistics. So, for example I wanted
to know how many objects were with the bit on and how many with the bit off.
Also the amount of memory those objects represents.

The method is:

primitiveGetStadistics
    | oop usedCount unusedCount results usedMemory unusedMemory usedCountOop
unusedCountOop usedMemoryOop unusedMemoryOop |

    usedCount := unusedCount := 0.
    usedMemory := unusedMemory := 0.

    self print: 'Start to check objects'; cr.
    oop := self firstAccessibleObject.
    [oop = nil] whileFalse: [
        (self isIntegerObject:  oop)
            ifFalse: [
                (self internalIsUsed: oop)
                    ifTrue: [
                        usedCount := usedCount +1.
                        usedMemory := usedMemory + (self internalByteSize:
oop). ]
                    ifFalse: [
                        unusedCount := unusedCount +1.
                        unusedMemory := unusedMemory + (self
internalByteSize: oop). ].
            ].
        oop := self accessibleObjectAfter: oop.
    ].
    self print: 'Finish to check objects'; cr.

    self print: 'Push stadistics'; cr.
    self pushRemappableOop:
        (self instantiateClass: (self classArray) indexableSize: 4).
    self pushRemappableOop:
        (self positive64BitIntegerFor: usedCount).
    self pushRemappableOop:
        (self positive64BitIntegerFor: usedMemory).
    self pushRemappableOop:
        (self positive64BitIntegerFor: unusedCount).
    self pushRemappableOop:
        (self positive64BitIntegerFor: unusedMemory).

    self print: 'Pop stadistics'; cr.
    unusedMemoryOop := self popRemappableOop.
    unusedCountOop := self popRemappableOop.
    usedMemoryOop := self popRemappableOop.
    usedCountOop := self popRemappableOop.
    results := self popRemappableOop.

    self print: 'Write stadistics in array'; cr.
    self storePointer: 0 ofObject: results withValue: usedCountOop.
    self storePointer: 1 ofObject: results withValue: unusedCountOop.
    self storePointer: 2 ofObject: results withValue: usedMemoryOop.
    self storePointer: 3 ofObject: results withValue: unusedMemoryOop.

    self print: 'Push result array in stadistics'; cr.
    self pop: 1 thenPush: results.




And as you may guess,
internalIsUsed: oop
    self inline: true.
    ^((self baseHeader: oop) bitAnd: UsedObjectBit) ~= 0


So then, from the image side, I can get statistics at certain point, and get
something like the attached screenshot.

Thanks.

Mariano



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

<<attachment: Picture 6.png>>

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

Reply via email to