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

Hello Folks,

We've recently upgraded our LDAP server from Centos (due to the IBM takeover of RedHat) to run on Ubuntu Server. The server has 64GB of RAM, and an 8 GB swap partition on a 480 GB SSD drive. We have a perl script that queries a main LDAP server and returns hits on first or last name as well as userid. The total volume of returned data is less than 4K.

This script ran for years on Centos, but will not run on Ubuntu, with an error output of "Out of memory!".

The ulimit command output shows identical values on both Centos and Ubuntu for all relevant memory limits, with:
max memory size (kbytes, -m) unlimited virtual memory (kbytes, -v) unlimited
The free command on the Ubuntu server shows 557MB of free uncached memory, with 61GB available:
# free -h total used free shared buff/cache + available Mem: 62Gi 557Mi 867Mi 5.0Mi 61Gi + 61Gi
I've searched here and via search engines for a solution, but can find none. Thanks for any idea you have to resolve this.

Replies are listed 'Best First'.
Re: Perl script works on Centos but not Ubuntu
by choroba (Cardinal) on Aug 25, 2023 at 18:35 UTC
    What version of Perl do you run on each server? 32 versus 64 bit?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Perl script works on Centos but not Ubuntu
by cavac (Prior) on Aug 28, 2023 at 08:34 UTC

    You didn't give us a lot of information. Here are some of my random thoughts on possible causes that i would check:

    1. Are there any security/safety systems active that may view the process as a possible threat or as a possible resource hog? What does your system log (/var/log/syslog and dmesg) say?
    2. On (modern'ish) Linux systems, ulimit isn't the only way to limit RAM allocation. There's also stuff like cgroups.
    3. AppArmor can limit access to system resources on a per-binary config. So your shell may have no limits, but your perl binary might have.
    4. Do you use the system perl or a custom one installed in a home directory. If you use a custom binary, that might have different memory limits than your shell (/usr/bin/* vs. /home/*).
    5. How does the script get started? Manually on the command line? Or by another process that may have lower memory limits (cron, etc) that get inherited by the perl binary?
    6. Without knowing the code you run, it's hard to know exactly what TYPE of memory you are running out of. Does your Perl script fork in any way and run into shared memory issues, for example?
    7. There could also be a problem mmap()ing a huge file into memory, perhaps? Creating a tie'd file in a small tempfs directory?

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Re: Perl script works on Centos but not Ubuntu
by NERDVANA (Priest) on Aug 25, 2023 at 19:57 UTC

    How long does it take the perl program to run out of memory? If there's a delay and then that message, it could be the perl script has some bizarre bug that really is chewing up memory. In that case, you can run the perl script under Devel::NYTProf to see which routines are the hottest, and narrow in on the problem.

    If the script runs out of memory immediately with no hot code paths, then possibly there is some insanely large allocation that immediately fails?