in reply to Re: memory not freed after perl exits. Solaris.
in thread memory not freed after perl exits. Solaris.

Can someone help me with the "$x='x' x 2**31" thing?

Try:

perl -e '$x="x" x 2**31'

All I've done is switch "s for 's and vice versa. That should now run on your Solaris system.

But you said that you'd got it to run by putting it into a script rather than running it as a one-liner. Did it have the desired affect?


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.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^3: memory not freed after perl exits. Solaris.
by Workplane (Novice) on Nov 25, 2010 at 10:28 UTC

    Thanks for the change to quotes. That has made it get further.

    But the result is then the same as before (when I saved it in a file and ran it from there)

    I can run up to **29, but not **30 or **31

    **29 takes about 4 seconds.

    $ perl -e '$x="x" x 2**31' panic: string extend at -e line 1. $ perl -e '$x="x" x 2**30' panic: string extend at -e line 1. $ perl -e '$x="x" x **29' $

    So why can't I run **30 or **31?

      Probably because your OS is setup such that each process can only address a maximum of 2GB. This is the normal configuration for 32-bit OSs.

      And when you do: $x = 'x' x 2**30; It first requests enough memory (1GB) to build the string in. It then requests another 1GB (for $X) to copy the string into. (Dumb, but that's the way it works!)

      As the perl executable is already consuming a few MB from startup, aftr you've allocated the first 1GB, there is not enough virtual memory left in the process to make the copy, so it fails.

      I was using a 64-bit OS which means each process can access much more memory.


      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.

      Out of curiosity, what output do you get from running the following on the command line?

      isainfo -v