On Tue, Apr 27, 2010 at 1:17 PM, Adrian Lienhard <adi@netstyle.ch> wrote:
BTW, Lukas had pointed out that my implementation is incomplete. So before integrating we should make sure the implementation covers all cases.

Adrian

Begin forwarded message:

> From: "Lukas Renggli" <renggli@gmail.com>
> Date: October 21, 2008 6:28:32 PM GMT+02:00
> To: "Pharo Development" <pharo-project@lists.gforge.inria.fr>
> Subject: Re: [Pharo-project] Size of objects
> Reply-To: Pharo Development <pharo-project@lists.gforge.inria.fr>
>
>> BTW, I think that would be a meaningful addition. Could somebody quickly
>> check the method to verify that I didn't do any miscalculation?
>
> The only problem I see is that variable objects might also have
> inst-vars. So you need to count the
>
> � �self class instSize * Smalltalk wordSize
>

I am not sure if I understood. Then the method should be something like this:

sizeInMemory
������ "Returns the number of bytes used by this object in memory (including its header)"

������ | headerSize instanceSize |
��� ��� headerSize := (self class indexIfCompact > 0 ifTrue: [ 4 ] ifFalse: [ 8 ]).
��� ��� instanceSize := self class instSize * Smalltalk wordSize.
��� ��� instanceSize := instanceSize + (self class isVariable
�������������� ifTrue: [ (self basicSize * (self class isBytes
���������������������� ifTrue: [ 1 ] ifFalse: [ Smalltalk wordSize ])) ]).
������ ^ headerSize + instanceSize

?

Thanks

Mariano

> part in any case.
>
> Lukas



On Apr 27, 2010, at 12:45 , Adrian Lienhard wrote:

> I once sent some code to the mailing list (search for thread named "Size of objects"). We should add this to the image. I think I named it #sizeInMemory.
>
> Adrian
>
> On Apr 27, 2010, at 12:03 , Mariano Martinez Peck wrote:
>
>> Hi. I don't know if "memory occupation" is the better name. I just want to
>> know the amount of memory that an object is occupying in RAM. I mean, the
>> amount of bytes.
>>
>> Is this possible ? if true, how ? � I would like to do it from both sides:
>> image and VM.
>>
>> I checked both but I didn't find anything.
>>
>> Thanks in advance
>>
>> Mariano
>> _______________________________________________
>> 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


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project