And then there's 1..100_000 that creates an array and 100,000 scalars at compile-time.

Really? Can you demonstrate that?

Because I see no evidence for it:

c:\test>perl -le"++$n for 1..1e2; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 7500 Console 1 5 +,716 K c:\test>perl -le"++$n for 1..1e3; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 3676 Console 1 5 +,712 K c:\test>perl -le"++$n for 1..1e4; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 6048 Console 1 5 +,732 K c:\test>perl -le"++$n for 1..1e5; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 5648 Console 1 5 +,720 K c:\test>perl -le"++$n for 1..1e6; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 8620 Console 1 5 +,736 K

Whilst the memory usage varies a little, it sometime goes down a few k when the notional size of this array increases by an order of magnitude?

Conversely, if you explicitly create an array of that size, the memory requirement increases by 100MB as expected:

c:\test>perl -le"@a = 1 .. 1e6; system qq[tasklist /nh /fi \"pid eq $$ +\"] " perl.exe 2664 Console 1 109 +,576 K

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^4: Why is const x const not a const? by BrowserUk
in thread Why is const x const not a const? by PerlGrey

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.