Good questions, but I'm not convinced of the practical utility. What's on your mind?
  1. That depends. You can look at the definition of the xpvcv struct in cv.h in the Perl sources for the basic information any subroutine (anonymous or not) has to carry around. Of course, a reference to a subroutine is just a scalar, and takes as much memory as any other reference.
  2. Yes, the number of operations in the function and the pads it uses all eat up a little bit of memory.
  3. Yes, anything that you'd think costs memory probably does. :)
  4. I believe so, based on the existence of some funky closure-like bugs, but I'm not an authority on the subject. I do know that it's reused on subsequent subroutine calls, if possible, to avoid the malloc-free cycle. I would imagine recursion has its own opportunities and challenges for optimizations.

In reply to Re: Space taken by a coderef by chromatic
in thread Space taken by a coderef by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.