Increase PHP Memory limit
-
Hi All,
I am running 1.5.6 on CENTOS7. I am running into an issue with setting the php memory limit so I can view reports on the web interface.Please see below for my log
/var/log/php-fpm/www-error.log [24-May-2019 12:25:22 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8192 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 622 [24-May-2019 12:17:46 America/New_York] PHP Warning: Error while sending QUERY packet. PID=6597 in /var/www/html/fog/lib/db/pdodb.class.php on line 591 [24-May-2019 12:17:46 America/New_York] PHP Warning: Error while sending QUERY packet. PID=6484 in /var/www/html/fog/lib/db/pdodb.class.php on line 591 [24-May-2019 12:09:11 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 936 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:57:21 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:36:52 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:28:24 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:23:22 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:17:20 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 11:08:25 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 10:57:13 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 81 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 10:52:53 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 89 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [24-May-2019 10:25:38 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 84 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [23-May-2019 14:18:39 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 78 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [23-May-2019 14:14:13 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 78 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [23-May-2019 10:35:22 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 85 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [23-May-2019 08:18:28 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 99 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [22-May-2019 09:15:31 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 602 [22-May-2019 08:46:46 America/New_York] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/fog/lib/fog/fogcontroller.class.php on line 1100 [22-May-2019 08:46:46 America/New_York] PHP Warning: array_diff(): Argument #2 is not an array in /var/www/html/fog/lib/fog/fogcontroller.class.php on line 1080
No matter where I change the memory limit (in the web UI under Fog Settings --> General or /etc/php.ini, or a couple of other places that are probably wrong) the error appears in my log saying the memory maxed out at roughly 256M. I was trying on 1.5.5 too (I upgraded to 1.5.6 as of this afternoon as a last ditch effort to get it to read my parameter). I am attempting to set it to anything that will allow reports to run.
Thanks!
fry_p -
@fry_p Quite often there are a couple of PHP inis. See if you can find them all using this command:
find /etc -type f -exec grep "memory_limit" {} /dev/null \;
-
this is in /etc/php-fpm/www.conf
the parameter is php_admin_value[memory_limit] = -
@EduardoTSeoane and @Sebastian-Roth you are both correct as always! I am running into the same error, but it is reading my new memory limit of 1024M. In particular, I am interested in the user tracking report. I am wondering if my table is much too large for the report to handle. Is there a way I may wipe the table up until 5/24/2018, or a year before today? I can open another thread as this is not particularly a fog issue.
-
@fry_p I use 1536M to list 15.225 pc’s.
Little question,
Have you restart php-fpm and httpd services?
I forget to do it when i did the change and…Understand, isn’t it?
-
@EduardoTSeoane I have restarted both services and also restarted the entire server. Since it is reading the new memory limit, I think it is trying to read too much data since we have had FOG for a long time. Years of user data that predates me at this job. I will try another restart of services though.
EDIT: Same issue after restarting services again.
-
@fry_p What you need to change is php-fpm memory limit. Its in a file called www.conf. Search the /etc directory with
find /etc -name www.conf
The location changes based on what version of php-fpm is installed.Inside that file there is a line
php_admin_value[memory_limit]
The default may be 128 or 256 depending on the version of fog that is installed. Based on the error, it might be set to 256M. I would start out by being conservative and update it to 384M. Save the config file and then restart php-fpm. Depending on the host OS the command may be
systemctl restart php-fpm
or just restart the FOG server. -
@fry_p said in Increase PHP Memory limit:
I am wondering if my table is much too large for the report to handle. Is there a way I may wipe the table up until 5/24/2018, or a year before today?
I am sure we can help you with this. Let’s try to find out how many entries you have in that table and then clean it up a bit.
shell> mysql -u root -p Enter password: ... mysql> use fog; ... mysql> SELECT COUNT(*) FROM userTracking; ... mysql> SELECT COUNT(*) FROM userTracking WHERE utDateTime < '2018-05-25'; ...
The last two queries should give you the numbers of all entries as well as the entries before 5/25/2018. Just to get an idea before we wipe it all. You may want to have a look at some of the entries as well. The following query should give you the last ten entries (seen from the beginning) up until the 24th of May 2018 in reverse order (the very latest of that day at first):
SELECT * FROM userTracking WHERE utDateTime < '2018-05-25' ORDER BY utDateTime DESC LIMIT 10;
Now if you are sure you want to delete those older entries you can go ahead an use
DELETE
instead ofSELECT
:DELETE FROM userTracking WHERE utDateTime < '2018-05-25';
Use the DELETE with caution! Make sure the prior SELECT query actually shows the entries you want to get rid of and not other ones.
-
@george1421 I found this when I initially did the search for the ini’s. I increased the amount and it is reading the new amount in the error log.
@Sebastian-Roth I am finding that my entries in this table don’t actually date back that far.
Yet my count for
SELECT COUNT (*) FROM userTracking;
Returns 217,893 entries.
The furthest back i can find is roughly January 30th 2019. Do you guys think that 217,893 is still too high? I can maybe try to prune anything older than two months as I really don’t need anything older.
By the way, here is the error I am getting.
/var/log/php-fpm/www-error.log [26-May-2019 05:53:59 America/New_York] PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 8192 bytes) in /var/www/html/fog/lib/db/pdodb.class.php on line 622
I set the memory to 1 GB for troubleshooting purposes only. I find it odd that it is only trying to use 8192 bytes but I still get a white screen when I am running the report. Specifically I am putting in myself as the username and my desktop as the PC.
-
@fry_p said in Increase PHP Memory limit:
I find it odd that it is only trying to use 8192 bytes
The error message might be a bit misleading. What this means is that it tried to allocate 8192 bytes beyond* the limit you specified in the ini file and there stops with a fatal error.
We added a search/pre-filter interface to the reporting for 1.5.6 (thanks to @Fernando-Gietz!). I had forgotten about this but now I wonder if you still get the memory exhaustion even if you try searching for a particular host oder username?
-
the php dont request the needed memory, it request for the next block. So:
When i has 256M it request another ±20M.
Then I increase to 512M. Then the system claims for another 20M.
Then I increase to 1024M and then the system claims for another 20MI repeat the actions to accure memory size to 1536M.
If it’s necesary to increase the memory a lot then maybe it’s necesary increase the TimeOut and ProxyTimeout httpd.conf paramenters.