Page 1 of 1

PHP error PHP Fatal error: Allowed memory size of X bytes e

Posted: Mon May 19, 2014 3:12 pm
by jamesjohnston
I am getting the PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate X bytes). I have increased the memory_limit in the php.ini file, which wouldnt go higher than 128M. I then saw the env.ini stuff and increased to 256M with no avail. Still getting the exact same errors. I have the max_input_time in the php.ini set to 600 and the max_execution_time set to 600. I have rebooted the server and tried restarting apache each time I make any changes. It was working fine for months, then today for some reason I have started getting these errors. What should I look into next? Let me know what else to try when you get a chance.

Thank you,
James Johnston

Re: PHP error PHP Fatal error: Allowed memory size of X byt

Posted: Mon May 19, 2014 4:34 pm
by jamesjohnston
The full error from the php-errors.log is "[19-May-2014 15:30:15] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 41 bytes) in C:\PATH\ProcessMaker-2_5_1-1\processmaker\workflow\engine\classes\model\om\BaseUsers.php on line 283"

Re: PHP error PHP Fatal error: Allowed memory size of X byt

Posted: Mon May 19, 2014 5:03 pm
by jamesjohnston
I am not sure if these are related, but in addition to the above error I am also getting These errors:

"[19-May-2014 16:01:26] PHP Warning: Invalid argument supplied for foreach() in C:\PATH\ProcessMaker-2_5_1-1\processmaker\gulliver\system\class.form.php on line 693

[19-May-2014 16:01:28] PHP Parse error: syntax error, unexpected ';' in C:\PATH\smarty\c\%%0D^0DA^0DAC18F9%%cases_ScreenDerivation1.html.php on line 55"

Re: PHP error PHP Fatal error: Allowed memory size of X byt

Posted: Tue May 20, 2014 7:50 am
by jamesjohnston
I fixed the other 2 problems, but I still have the memory issue. It is only occuring when I click on an Unassigned Case to show the Claim this case window.

Re: PHP error PHP Fatal error: Allowed memory size of X byt

Posted: Tue May 20, 2014 10:21 am
by jamesjohnston
I found the issue. Apparently there was a user that was added without a USR_UID in the users table. He also had some other fields blank in that table as well. Anyway this was causing an issue witht he Unassigned cases since they have a blank APP_CURRENT_USER which was filling in this user. AFter I deleted the user from the users table everything is now working correctly.

Re: PHP error PHP Fatal error: Allowed memory size of X bytes e

Posted: Sat Oct 13, 2018 3:24 pm
by mickeifin453
"Hey jamesjohnston,
Your first course of action is to increase your memory limit but remember increase the memory limit programmatically early on in your code, before your process runs out of memory. If you do it this way, you can give PHP extra memory only when that piece of code gets called rather than increasing the memory limit for all PHP processes.

Please set the code:
<?php
ini_set('memory_limit', '1024M'); // or you could use 1G


If by increasing the memory limit you have gotten rid of the error and your code now works, you'll need to take measures to decrease that memory usage. Here are a few things you could do to decrease it:
If you're reading files, read them line-by-line instead of reading in the complete file into memory. Look at fgets and SplFileObject::fgets.
Upgrade to a new version of PHP if you're using PHP 5.3. PHP 5.4 and 5.5 use much less memory.


"

Re: PHP error PHP Fatal error: Allowed memory size of X bytes e

Posted: Sat Oct 13, 2018 4:42 pm
by mickeifin453
Hey jamesjohnston,

Your first course of action is to increase your memory limit but remember increase the memory limit programmatically early on in your code, before your process runs out of memory. If you do it this way, you can give PHP extra memory only when that piece of code gets called rather than increasing the memory limit for all PHP processes.

Please set the code:
<?php
ini_set('memory_limit', '1024M'); // or you could use 1G


If by increasing the memory limit you have gotten rid of the error and your code now works, you'll need to take measures to decrease that memory usage. Here are a few things you could do to decrease it:
If you're reading files, read them line-by-line instead of reading in the complete file into memory. Look at fgets and SplFileObject::fgets.

Upgrade to a new version of PHP if you're using PHP 5.3. PHP 5.4 and 5.5 use much less memory.