[Solved] Memory error with archiving

Hello guys

I have about 2000 visitors in one day.
Piwik worked correctly for one week.
But now, I get the following error, when my crontab tries to launch the update :

Error in the last Piwik archive.php run:
2 total errors during this script execution, please investigate and try and fix these errors. First error was: Got invalid response from API request: http://www.mywebsite.fr/analytics/index.php?module=API&method=VisitsSummary.getVisits&idSite=1&period=month&date=last2&format=php&token_auth=1c99eca7c6be7c9d5388f09bb9eb2996&trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of ‘memory_limit’ in your php.ini file.

So, i have increased the following parameters :

On /etc/php5/cli/php.ini
I have changed :


memory_limit = -1

to


memory_limit = 512

But now, i have this error :

PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0

In my piwik config file (global.ini.php), i have :


; Minimum adviced memory limit in php.ini file (see memory_limit value)
minimum_memory_limit = 128
; Minimum memory limit enforced when archived via misc/cron/archive.php
minimum_memory_limit_when_archiving = 512

What should i do please ?

Could you temporarily try to bump up memory to 1024? remember to restart apache once the changes are made. Im curious to see if this helps.

Hi
which parameter should i increase please?

memory_limit in the php.ini file
or
minimum_memory_limit_when_archiving = 512 in global.ini.php file

I restart apache2 in each update.
I have already tried minimum_memory_limit_when_archiving = 1024 but i still had the first error.

try both but in steps 1st then 2nd to see if that helps.

Still the same error :


PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0

On the memory limit

On /etc/php5/cli/php.ini

to
memory_limit = 512(or what ever you have now)

can you try to make the change define like below

memory_limit = 512M

Yes you right
512M is the correct syntax.
However, i still get the first error now :


Error in the last Piwik archive.php run:
2 total errors during this script execution, please investigate and try and fix these errors. First error was: Got invalid response from API request: http://www.mywebsite.fr/analytics/index.php?module=API&method=VisitsSummary.getVisits&idSite=1&period=month&date=last2&format=php&token_auth=1c99eca7c6be7c9d5388f09bb9eb2996&trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file.

I set at 1024M now.
I will check if everything is ok.

There is also a global.ini.php in the piwik folder if your other test fails try to see if upping that to 512 helps(assuming its lower than 512 now)

Same issue
So i have set

; Minimum adviced memory limit in php.ini file (see memory_limit value)
minimum_memory_limit = 128

to

; Minimum adviced memory limit in php.ini file (see memory_limit value)
minimum_memory_limit = 512

Wait and see

To change the memory limit in PHP edit your php.ini file and restart the server. Set to 512M

the error message says 262144 bytes: your PHP memory limit is 256Kb… too small indicating an error

Still the same error …

You wouldnt happen to have a .htaccess file in the same folder as the piwik php.ini? If so it might be what is limiting the error?

Is there any error logs being generated in your apache web logs? That could point out the issue?

Hi

I have solved the issue i think
I have increased the susohin.memory_limit to 512M

ok great to hear! Can you change the topic to solved? Is this site a wordpress site?

This is a prestashop website
thanks for your help !
You are great :wink:

Friendly reminder: don’t edit global.ini.php. If you directly edit the file, you will lose your changes when you upgrade Matomo. If there is no config/config.ini.php (usually found in the top directory, the folder named matomo) you can make a new empty file, and put [General] at the top of the file.

These are a minimum. Changing them can help a bit but not dramatically. The maxi`mum limit is the most important thing and it is set elsewhere: in the php config files, on your operating system.

So yes, if you want, you can set them to -1. It’s not expected to improve performance, since PHP is a high level language and will use both the minimum and maximum in the most efficient way.

​More important is to locate the php.ini file used by your OS and set the following values:

 
​memory_limit = 2G      
max_execution_time = 0
log_errors = On
display_errors=Off

​People sometimes change that 2G to 4G or 6G.

Wanted to add a note here for whoever other users facing same issue.

I wanted to increase my memory as well, and ended up in the /path/to/matomo/config/config.ini.php to modify it under [General] by adding this:

[General]
memory_limit = 512M

Then the trick is to reboot your server, I just did a sudo reboot in SSH / terminal.

Once server reboots, you’ll notice in Administration > Diagnostic > System Check that Memory limit is now 512M.