Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Memory usage in Perl on Windows systems

by steveskentzos (Initiate)
on Jun 22, 2010 at 19:26 UTC ( #845951=perlquestion: print w/replies, xml ) Need Help??

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 (Pope) 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 (Pope) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://845951]
Approved by ikegami
Front-paged by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2021-10-22 01:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?