in reply to Measurement of physical memory

If you want to know the length in bytes of that message, you can use length($message), but this is only vaguely related to how much memory the string takes up.

Replies are listed 'Best First'.
Re: Re: Measurement of physical memory
by theorbtwo (Prior) on Jul 16, 2002 at 23:05 UTC

    Note, BTW, that with the Wonderful World of utf8, the number of characters in $message and it's size in bytes are not neccessarly the same. The above normaly gives the length in characters; to get the length in bytes,

    use bytes (); ... $sizeof=bytes::length($message);
    But remember that doesn't count all the overhead of a scalar. (28 bytes on most boxes, IIRC, but there are very few circumstances where you should care.)


    Confession: It does an Immortal Body good.

    Update: Fixed tpyos.