http://www.perlmonks.org?node_id=845951

steveskentzos has asked for the wisdom of the Perl Monks concerning the following question:

So... I'm trying to find out if there are memory limitations on Perl running on Windows systems, something similar to ulimit. Besides simply writing code that uses less memory, are there ways to boost the amount of memory Perl can use before crapping out? Does it matter if it's a 32- or 64-bit system? Thanks a bunch.
  • Comment on Memory usage in Perl on Windows systems

Replies are listed 'Best First'.
Re: Memory usage in Perl on Windows systems
by BrowserUk (Patriarch) on Jun 22, 2010 at 20:58 UTC

    If you are stuck with a 32-bit Perl, you will find yourself limited to at most 2GB even if you have a large swap file enabled.

    However, if you are using an appropriate version of windows, it is possible to extend that limit to up to 3GB (even if you don't have 3GB of physical ram installed). This requires 2 steps:

    1. You have to enable your system to handle it by adding the /3GB switch in boot.ini.
    2. You have to enable perl.exe to handle it by adding the /LARGEADDRESSAWARE flag in the executable.

      This can be done using editbin.exe.

    Some details on this can be found at MS. Google for "/3GB" and/or "/LARGEADDRESSWARE" for more.

    The interesting thing is that if you are running a 64-bit windows, but a 32-bit Perl--which makes some sense as there are far fewer modules readily available for 64-bit Perls, then you can gain significantly by editbining your 32-bit Perl executable to be /LARGEADDRESSAWARE

    Without that enabled, the most memory I've succeeded in allocating (in 1MB chunks) with Perl 5.8.9 is 1.8GB. But a simple editbin /LARGEADDRESSAWARE \perl32\bin\perl.exe, and I can now allocate 3.767GB.

    Which is an interesting conundrum to explain, but in large part negates my reasons for using a 64-bit perl. Because although I have allocated more than 10GB using perl64, once it gets into swapping, the system runs like a dog, so I don't go there other than for the experiment. And 3.7GB is close enough to my 4GB physical ram that, with the easy availability of so many more modules, I might regress.


    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.
      Hi,

      Thanks a lot for sharing this information.

      It worked for me with the editbin.exe from VisualStudio2019 CommuntyEdition with installed C++ Module.
      Tested with StrawberryPerl32 on Win7/64 up to 4GB Memory

      I'm workin with really huge OpenStreetMap (OSM) XML Files - up to 50GB.
      No Problem with this Patch, without Perl crashes at 1,8GB.


      Thanks again
      Christian
      www.openandromaps.org
Re: Memory usage in Perl on Windows systems
by ikegami (Patriarch) on Jun 22, 2010 at 19:36 UTC
    I don't know if it's possible to add a limit, but there's definitely none by default. Perl has access to entire virtual memory space minus what the system reserves (so 2GB for 32-bit builds, oodles for 64-bit builds).
Re: Memory usage in Perl on Windows systems
by Anonymous Monk on Sep 18, 2013 at 17:24 UTC
    Try modifying the DesktopHeap via the registry:- HKLMSystem\CurrentControlSet\Control\Session Manager\ SubSystems\ Open the "Windows" value and edit the "sharedSection=xxxxyyyyzzzz" value. On a 32 bit system increse the yyyy value to 12288, or on a 64 bit system increase the yyyy value to 20480.