I am getting the following error when viewing the ‘Behavior’ → ‘Pages’ tab. Specifically this happens when viewing a Period “Date Range”. The range to be a prior week (ex: From: Nov28, 2022 - To: Dec 4,2022). This does not happen when Selecting ‘day’, ‘week’, ‘month’ or ‘year’. It only happens when using the ‘date range’ period.
Fatal error : Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /srv/www/matomo/core/DataTable/Row.php on line 361
Matomo encountered an error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) (which lead to: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes))
Any information on what might be happening to where I should investigate would be appreciated.
Fatal error : Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /srv/www/matomo/core/Common.php on line 300
Matomo encountered an error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) (which lead to: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes))
What the logs are saying is that you don’t have enough PHP memory to do the range request. Ranges are not archived in advance and therefore needed to be archived temporarily when you are doing the range request, archiving takes PHP memory, and in this case, you don’t have enough. If you can, try to raise the PHP memory limit.
Step 1:
For any “Tried to allocate …memory…exhausted” error, determine whether php-fpm or * php-cli was exhausted. Some clues:
errors during command line execution are php-cli
errors during core:archive for example, are php-cli
if the error includes cli=0 in the error message, it is from php-fpm
if the error was during an API request, such as requesting data to export to your data tool, or to export a large chunk of Visitors >> Visits Log raw data, it’s php-fpm
errors from doing anything in the Matomo interface are php-fpm
Yours is ‘Behavior’ → ‘Pages’ tab. That’s the graphic user interface, so it is the last case, above.
Step 2A, for php-fpm (your case)
The memory setting to fix is in the php-fpm module.
Find the config file location by forcing the Matomo server to serve a file running phpinfo(). Search the result for “config”, to see the config location.
Edit that config file. Double the memory_limit setting. Save.
Please restart sudo systemctl restart php{version}-fpm
for example, in my Ubuntu environment: sudo systemctl restart php8.2-fpm
Step 2B, for php-cli (if anyone is reading this and needs CLI instructions!)
(Optional) You can test this ad hoc by executing with the memory_limit in the command: php -d memory_limit=8G console core:archive
If this error occurred while running php console core:archive you must determine where is the config file for your php-CLI. This is usually different than the file which configures your server PHP. Find the location this way: php -i | grep "Configuration File"
Then edit that file to increase the memory_limit. You can double it. Many users set this limit for 4G or 8G. Try at the very least 2G.
After you think you set the memory_limit = 4G or at least memory_limit = 2G, check it: php -i | grep memory_limit