You're generally limited by the amount of memory you have available to your process, rather than the stack size, as perl's variables aren't allocated on the stack. There are a couple of caveats, though.
- Arrays require a chunk of contiguous memory that's no smaller than (array_size * pointer_size) in bytes. If your array is 100 elements long and have 4 byte pointers, you'll need at least 400 bytes contiguous.
- When extending an array, perl may temporarily need a contiguous chunk of memory that's 1.2 times larger than the current size of the old array's contiguous memory needs. So if you extended the array in the previous point, perl would need a chunk of memory that's 480 bytes.
- Each string need to be in contiguous memory, so a 10K string would need a contiguous chunk of memory 10K in size
- Perl uses rather more memory than you might think, so it's easy to chew up a lot, just in absolute terms
The contiguous memory needs are often what gets you. If perl needs to extend a 50M element array it'll need temporarily another 240M of contiguous memory. Your process may have that much free in absolute terms, but not a single piece that big. (And some OSes and C libraries limit the size of a single memory allocation)
There are some tricks you can use, for example preextending and then shrinking an array, but if you need that you're dancing at the edge of disaster, so you might want to consider other solutions. (Which is why I'm not listing them. If you figure them out, you'll figure out when to use them as well, which is more useful, and much more difficult to explain)
You might also want to look at Devel::Size as something to work with in development. It'll give you an idea of how much memory your variables are using, which can help in planning coding strategies.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.