PHP Fatal error: Out of memory (allocated 28311552)

Reading Time: < 1 minute

While checking out the TrainSEM website, which runs aMember software, I got a PHP error instead of the usual page:

Fatal error: Out of memory (allocated 28311552) (tried to allocate 40961 bytes) in /home/trainsem/public_html/amember/library/Am/abc.php on line 343

I checked aMember Setup > Configuration, and got:

I doubled the VPS memory_limit to 64M in php.ini (via WHM) and rebooted but the above errors did not go away.

After reading a few threads on different forums, I solved it.

Table of Contents

Probable Cause

The likely cause of the error started a few days ago, when I was in WHM > Apache Configuration, which has a feature called Memory Usage Restrictions. Unlike other tools in WHM, this one just goes ahead and changes the RLimitMEM value based on previous usage. In my case, the value (in httpd.conf) was 55924053.


After reading about my error in other forums, I saw a lot of advice to increase the value of memory_limit in php.ini, including one example upping it to 999M! Luckily I saw other comments suggesting that this isn’t the way to tame scripts with memory leaks and to also check Apache’s httpd.conf for the RLimitMEM value.

Solution

If you have root access (VPS or dedicated server), look for this value by typing at an SSH prompt:

grep -i rlimit /usr/local/apache/conf/httpd.conf

If there is a value, e.g. RLimitMEM 55924053, comment it out with “# ” and restart Apache.

This fixed my problem and might help others. Be sure to backup php.ini before you try this.

Mastodon