Memory limit when archiving

I already read all existing topics regarding this issue, but no solution seems to work with me.

Error: Got invalid response from API request: ?module=API&method=API.get&idSite=2&period=year&date=last2&format=php&trigger=archivephp. Response was ’
Fatal error: Out of memory (allocated 358875136) (tried to allocate 8388608 bytes)

The amount 358875136 (approx. 342M) appears nowhere in my settings.

I already tried the following:
In php.ini I set:
memory_limit = 4G

In global.ini.php I set:
minimum_memory_limit_when_archiving = 4096

And I also tried:
minimum_memory_limit_when_archiving = -1

I tryied setting memory_limit when calling:
/usr/bin/php /home2/cbooks/public_html/console core:archive --url=http://cbooks-piwik.net/ --php-cli-options="-d memory_limit=4G"

Whatever I put any place, the error and the amount (around 342M) stays the same.

Any ideas welcome!

Sorry that nobody replied here.
(And by the way: I feel your pain. PHP settings are less friendly than Apache settings, personal opinion. They’re logical, just too powerful maybe.)

A crucial first step is to not edit the wrong php.ini. You could be using PHP 8.3 and by mistake you edit the config of PHP 7.4. Even worse, you could accidentally edit a setting for the browser php (that will be the pink and blue screen seen when you run phpinfo()). That doesn’t help Matomo archiver, because core:archive uses the php-CLI setting

  1. Find the correct, effective php.ini file. php -i | grep php.ini
  2. Edit that file. 6G is actually okay. memory_limit=6G
  3. Restart the server. In Apache: sudo systemctl restart apache2
  4. Confirm it worked: php -i | grep memory_limit
1 Like