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

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?

Replies are listed 'Best First'.
Re^4: memory not freed after perl exits. Solaris.
by BrowserUk (Patriarch) on Nov 25, 2010 at 10:42 UTC

    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.
Re^4: memory not freed after perl exits. Solaris.
by marto (Cardinal) on Nov 25, 2010 at 12:48 UTC

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

    isainfo -v