It’s hard to describe this issue, but don’t point me at “edit php.ini” because that is not the right answer. I’m looking for how to pass the memory_limit parameter on the command line to the php process being forked.
The error log will show stuff like this:
ERROR [2015-07-29 07:40:28] Got invalid response from API request: ?module=API&method=API.get&idSite=6&period=month&date=last2&format=php&trigger=archivephp. Response was ’ Fatal error: Allowed memory size of 83886080 bytes exhausted (tried to allocate 10399 bytes) in /home/piwik/public_html/core/DataTable.php on line 1324 ’
Raising the memory limit in php.ini does not solve the problem because it increases the memory load on the webserver which doesn’t need it set that high.
ERROR [2015-07-29 05:11:18] Got invalid response from API request: ?module=API&method=API.get&idSite=6&period=year&date=last2&format=php&trigger=archivephp. Response was ’ Fatal error: Allowed memory size of 176160768 bytes exhausted (tried to allocate 8388608 bytes) in /home/piwik/public_html/core/DataTable.php on line 1362 '
ERROR [2015-07-29 05:28:44] 1 total errors during this script execution, please investigate and try and fix these errors.
I can’t just keep increasing the memory size every second day since adding the “required” php modules modules already increased the “web server” memory usage to levels that shouldn’t be necessary just to track statistics.
Having the cronjob do this:
/usr/bin/php-cli -d memory_limit=256M /home/piwik/public_html/console core:archive
results in the memory_limit being ignored because it appears the console is forking php processes without passing the -d memory_limit variable.
The site’s it’s “falling over” on that requires over 200MB to deal with, are the largest two sites using it.
And I know the variable is being used by the cronjob:
/usr/bin/php-cli -d memory_limit=256M -i |grep memory_limit
memory_limit => 256M => 256M
So I’m at a loss as to how to get the Piwik console to use a different memory_limit than the web server.