I have just downloaded a fresh new WordPress to a virtual server where a WP and MediaWiki are already running smoothly. The memory_limit in php.ini is set to 256MB. But for some reason WP thinks it is limited to only 2MB, see Apache log entry below.
[Sun Nov 19 08:50:21.692866 2017] [:error] [pid 74814] [client 109.81.213.117:59968]
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate
131072 bytes) in /var/www/foo.bar/subdomain/wp-includes/capabilities.php on line 452
When I print phpinfo() from the index.php file of my new WP, it shows the 256MB limit so there is no second secret php.ini configuration for this subdomain or directory.
I also tried to find a mischievous setting of memory limit in .htaccess or php file but with no avail. (grep -r "memory_limit" .)
Any ideas where this 2MB limit could be coming from?
UPDATE
I put ini_get('memory_limit'); exit; in the middle of wp-settings.php where it is including other files. Sometimes it writes the 256MB as it is supposed to, sometimes it dies in /var/www/iurium.cz/daily/wp-includes/wp-db.php with the error of 2MB. The behavior is quite random.
What else can influence the memory limit if not htaccess, php.ini or ini_set? Does it have to do with PHP at all? Can it be set in the system somehow?
Make sure your memory_limit value is 256M (not 256MB).
The PHP description of resource limits calls for 256M https://www.php.net/manual/en/ini.core.php#ini.memory-limit
You can use phpinfo() or ini_get('memory_limit') to check the value.
If memory_limit doesn't match the expected format, PHP will default to 2M (2097152 bytes)
Having the same problem. No idea what's causing it. Alleviated it by using @ini_set('memory_limit', '512M');
in wp-config.php
Some plugin (or theme file) is changing memory_limit somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With