Well, I have run a test on my Apple MacBook and SparkyLinux using Perl 5.40. But both of those systems are 64-bit with a modern Perl, and in each case, Perl seems to have limits but not sure why. I don't have unlimited memory in my computers, but I tried to create a string that is 4GB long, and Perl immediately said "Out of memory" and the program ended. So, it didn't even try to create the string. Then I tried to create a string that is 1GB, and after some time, it displayed a message that says "Killed", and then I was staring at the # prompt in Linux. So, then I tried to create an 800 MB string, and it worked. And this is how much memory I've got:
# free total used free shared buff/cache + available Mem: 3290320 1522528 1677380 152628 397604 + 1767792 Swap: 0 0 0

So, I can't really tell if my theory is right. I mean I would need a computer with 2 Exabytes of memory to see if it would work. But it seems I have more than 800 MB of free memory, yet it won't allow me to create a 1 GB string. I don't understand why it kills the process. Well, anyway, I just wanted to know what's a safe size for a string. So, it seems that if I create a program that works with 1 GB strings, it will run on most modern machines. But if I write a program that relies on creating and working with 2GB or 4GB strings, then that might fail on some systems. I guess, the bigger the string, the fewer computers will be able to handle it.

Btw I also checked the Perl machine used in this online site https://www.onlinegdb.com/online_perl_compiler, and I was able to create a 1 GB string with no problem! Yay! Now, when I tried to create a 1.5 GB string, my program just stopped working without any error message. So, I guess, they limit how much memory they allocate for anonymous users online and if a process tries to use more, it gets killed silently.


In reply to Re^2: maximum length of scalar in theory by harangzsolt33
in thread maximum length of scalar in theory by harangzsolt33

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.