Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to burn 100 megabytes in one line and still get the wrong answer

by flyingmoose (Priest)
on May 17, 2004 at 16:43 UTC ( #354029=note: print w/ replies, xml ) Need Help??


in reply to How to burn 100 megabytes in one line and still get the wrong answer

C:\WINNT>perl -e "print 00x888888888;" Out of memory!

Amazing, it returns really quickly. Anyone care to speculate why this dies in a split second? Is the memory management engine really that smart? I didn't think Perl had any self-imposed ulimits or anything like that, and the Windows/Linux behavior is identical. You'd think it would slurp all available memory, but it looks like it doesn't even get close to trying.


Comment on Re: How to burn 100 megabytes in one line and still get the wrong answer
Download Code
Re: Re: How to burn 100 megabytes in one line and still get the wrong answer
by Ven'Tatsu (Deacon) on May 17, 2004 at 17:12 UTC
    I belive perl will see the 'x' operator and try to allocate the necessary memory in one block. The OS will quickly not find a memory range large enough and fail the request, prompting perl to die. The alternative that would cause perl to die slowly would be if 'x' allocated a small string, copied it's first parameter into it until it ran out of space, then allocated a slightly larger sting, copied the old sting in, de-allocate the old sting, then continued to copy the first parameter until it ran out of room again. But that would be horribly inefficient. (even for perl =)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://354029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-07-05 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls