Memory Limit on Archiving Cronjob

Hello guys,

I’m experiencing a problem, which seems to be reoccuring in the forums and is never really solved.

I’m running the archive script in a cronjob like this twice a day ( I had this once an hour before but changed it after the
first out of memory message ):
php /absolute/path/to/piwik/console core:archive --url=https://www.domain.com/piwik/ >> /absolute/path/to/piwik/piwik-archive.log

which worked fine up to june.
Then I experienced the first out of memory error:

Got invalid response from API request: ?module=API&method=API.get&idSite=1&period=year&date=last7&format=php&trigger=archivephp.
Response was 'PHP Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 2 bytes) in /absolute/path/to/piwik/core/DataTable.php on line 1325

The allocated bytes vary from call to call but the memory size is everytime the same, which therefore funny, since the memory limit never was 768M as statet, but 368M

I then contacted my hoster to increase the memory limit, which he did ( from 368M to 1024M ) in the global
php.ini file ( it’s our own managed server ). Calling phpinfo() assures me this is correct and up to date

Now I received yesterday the same error:

Got invalid response from API request: ?module=API&method=API.get&idSite=1&period=year&date=last7&format=php&trigger=archivephp.
Response was 'PHP Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 2 bytes) in /absolute/path/to/piwik/core/DataTable.php on line 1325

Which is again the wrong memory size ( is this hardcoded ? )
So what can I do? How can I get the real error message since this seems to be a stub, the memory size is DEFINITLY not set to 768M

I currently have less than 2000 visitors a day, so increasing the memory limit again can’t be the best solution since this is not what I’d call
a high traffic page.

I hope someone has an idea how I can solve this and it’s not closed with the default “increase memory limit” answer like the others.

I’d also accept a way to archive the periods in seperate calls if this is somehow a possible solution.

Thanks beforehand,
Chrissli

It appears that when Piwik is run from CLI it is picking up the hard coded:

minimum_memory_limit_when_archiving = 768

in the global.ini.php file. You may want to change that value and see what happens.

I don’t understand why this happens. It should be getting the memory_limit from php.ini but that doesn’t seem to work in this case. Perhaps you could create a test file that grabs the data and see what you get. It could also be something to do with the version of PHP that you are running.

1 Like

Hell Valdhor,

apparently it worked!
Thanks for this suggestions.
I would wait until tomorrow to see if the next automated run is still fine and then mark your post as the answer.

Thanks again, it seems the cronjob keeps running without errors.