[Vm-dev] Re: [Pharo-project] is it possible to know the memory
occupation (bytes) of an object?
Henrik Johansen
henrik.s.johansen at veloxit.no
Tue Sep 28 09:05:11 UTC 2010
On Sep 28, 2010, at 6:46 40AM, Nicolas Cellier wrote:
>
> 2010/9/27 Eliot Miranda <eliot.miranda at gmail.com>:
>>
>>
>>
>> On Mon, Sep 27, 2010 at 12:20 PM, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
>>>
>>>
>>>
>>>
>>> On Wed, Sep 22, 2010 at 12:34 PM, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
>>>>
>>>>
>>>> On Wed, Sep 22, 2010 at 12:12 PM, Henrik Johansen <henrik.s.johansen at veloxit.no> wrote:
>>>>>
>>>>> On Sep 22, 2010, at 9:59 40AM, Adrian Lienhard wrote:
>>>>>
>>>>>> Some notes:
>>>>>>
>>>>>> - What should be answered for small ints? 1 sizeInMemory -->8. That's wrong. Shouldn't this answer 0?
>>>>>
>>>>> Philosophical question really, imo both 4 (Again, in 32bit images at least) and 0 would be "correct" answers in their own ways. 8 is definitely wrong though :)
>>>>> The method comment should probably highlight which definition is used.
>>>>>
>>>
>>>
>>> So....what should we consider for SmallInteger ? 4 bytes or 0 bytes?
>>
>> 0 bytes, obviously. The only space occupied by a SmallInteger is the space of the slot containing it. There is no SmallInteger object beyond the slot.
>>
>
> Or from another POV, it's 4, the size of the slot. But we don't count
> the size of the slots, they are already counted in the containing
> object, that's why it should answer 0.
>
> Nicolas
Yeah, those were the two I were thinking of, and Mariano also summed them up nicely in a previous mail.
When you want to use it for counting up total space usage of objects, 0 is the one it should answer.
Cheers.
Henry
P.S. I still stand by my statement that the comment should highlight this is the reason why 0 was chosen :)
More information about the Vm-dev
mailing list