I have a Web App that's running on a LAMP Stack and it's been working fine until yesterday when a script responsible for sending OTPs via email no longer worked. Upon further investigation, it seemed that PHP wasn't running at all.
When I hit the "Log In" button that fires the PHP script to processs the OTP log in, I just get an error that the PHP script was returning an invalid Blank JSON String. I tried inserting log statements to the function call just to see if the script is running, but it just kept on giving that error which convinced me that php script was not running.
I checked the logs over at /var/log/apache2/error.log
, and I saw there the error that went something like "PHP Allowed Memory 2xxxxxxx (tried to allocate 9301 bytes) Exhausted", and it was triggered by Composer's ClassLoader PHP script, which led to the PHP script crashing.
I've tried increasing the memory limit in the active php.ini
file and resetting both the server and the apache2 service, but to no avail.
Then earlier today, the Web Server sent the perodic emails it had to send, and that used PHP that was run using a cronjob. I checked the CLI php limit, which is -1
. I'm sure it's a bad idea to set -1
as the memory_limit
in php.ini
, but the Web App is being used in production and I have to bring it up somehow.
Clearly, there's a PHP Script that's gone awry and is either leaking memory, not getting closed properly, or not getting cleaned up properly.
Sadly, I don't have time to scour the depths of my code in order to check PHP script is causing all these issues.
Is there a way to do the following:
- Clear the Memory Allotted for PHP to make sure that it's available.
- Check which scripts are exhausting the memory, and a possible remedy.
I feel like I'm overlooking something simple. Any leads would be appreciated.