Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Syntax error makes perl hang

by cfreak (Chaplain)
on Aug 15, 2005 at 20:53 UTC ( [id://483989]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Syntax error makes perl hang
in thread Syntax error makes perl hang

I tried assigning it to an array and took out the '_':

@foo = ('pfo' .. 'pctpfo' );

This didn't work, in fact I let it run to see if it would eventually come up with something ... instead it took my machine with it (fun to cause a hard reboot in Linux every now and then right?). Anyway that makes me suspect there is some kind of memory leak.

Oddly enough its not the length of the string: Using 'aaaaaaaaa' worked just fine so it must have to do something different when there are several different characters

Replies are listed 'Best First'.
Re^5: Syntax error makes perl hang
by gellyfish (Monsignor) on Aug 15, 2005 at 21:14 UTC

    Just try:

    perl -e "@foo = ('pfo' .. 'pct'); print @foo"
    and I think you'll start to get the picture. It's not az memory leak - it's just you are building a ridiculously large array.

    /J\

      Sure. The question is, why is it building the array during a -c check? I guess if perl sees that neither the start nor the end can vary, then it does it at compile time, otherwise it differs it to runtime. That feels weird to me, and obviously to a few others as well. Although further checking shows that it is at least consitent, and not dependent on what charactes are use (which is what i thought before).


      ___________
      Eric Hodges

      Except that 'aa' ..'aaaaaaaa' which works is a bigger array than 'pfo' .. 'pctpfo', unless I'm completely misunderstanding how it increments them. I'm guessing there is some kind of optimization in that case? ... Either way why does Perl still allocate the memory during the -c check? (my machine crashed while using -c)

      If it is just the size I suppose there's not a bug per se, but it would be nice if there was some kind of brake to keep Perl from running away with all the memory. I still say there is a bug though, at the very least -c shouldn't allocate the memory.

        perl attempts some basic optimisations during the compile phase. One of which is to precalculate constant lists. Since both arguments to the range operator are constant the list it produces will be constant and can be precomputed.

        Well I was going to try this out and give some actual figures, but when I got to 'pfo' .. 'pctpf' it swallowed all the swap and I decided to reboot rather than wait for it. 'aa' .. 'aaaaa' was fine - producing 475229 elements.

        /J\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-03-28 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found