in reply to Re^5: Why is the size even bigger after pack?
in thread Why is the size even bigger after pack?

You mentioned it's in previously allocated memory

why??Isn't it created on the fly?

Perl allocates more memory than required for string, that's what xpv_cur/xpv_len is there for

Replies are listed 'Best First'.
Re^7: Why is the size even bigger after pack?
by ikegami (Patriarch) on Nov 04, 2011 at 03:01 UTC

    No, the SV body isn't created at all for SVt_IV scalars.

    A SV usually has a head block and a body block (that's in addition to any string buffer, etc). SVt_IV scalars, rather exceptionally, don't have a body. Or rather they have a body, but it's location overlaps the head so that it never needs to be allocated.

    5.12, 64 bit ints, 64 bit floats - - -+ <---+ : | : +04 | Usual SV head SVt_IV : | --> +-----------------+ --> +-----------------+ +08 | | Pointer to body ------+ | Pointer to body ------+ +04 | | | +04 | | +0C | | | | | +08 +-----------------+ | +08 +-----------------+ +10 | REFCNT | | | REFCNT | +0C +-----------+-----+ | +0C +-----------+-----+ +14 | FLAGS | SVt | | | FLAGS | SVt | +10 +-----------+-----+ | +10 +-----------+-----+ +18 | PV ---> +---------- | | IV/UV | +14 | | ... | +14 | | +1C | +---------- | | | +18 +-----------------+ | +18 +-----------------+ +20 | Usual SV body | +-----------------+ <---+ | NV | | | +04 | | +-----------------+ +08 | CUR | | | +0C | | +-----------------+ +10 | LEN | | | +14 | | +-----------------+ +18 | IV/UV | | | +1C | | +-----------------+ +20
      Can you represent it with an image instead?
        That is an image. Be more specific.