0

Unusually, I would like to reduce the wordpress / woocommerce memory limit, as it leads to too high memory consumption on the server.

I'm not able to change my php memory-limit variable due to my Hosting Service (Siteground).

Nevertheless, it should be possible to set the memory limit for Wordpress.
I have already tried this via the wp-config file.

While Wordpress internally shows me the value I defined for the variables under Site Health, WP still doesn't seem to use these values.

Furthermore, under Woocommerce -> Status I am still shown a different value for the memory limit (the value of the PHP variables, not the WP variables).
Also an error message regarding critical allowed memory size also indicates that the value of the wp-config file does not apply.

7
  • 1
    reducing the memory limit won't reduce the amount of memory that your site uses, it will still attempt to use the same amount of memory. If you are successful you'll instead see PHP fatal errors when your site tries to use memory and hits the limit. If your goal is to reduce the amount of memory your sites request use, the memory limit is not the solution. It's also possible siteground prevent you from changing the memory limit to avoid you increasing it past their allowance.
    – Tom J Nowell
    Sep 8 at 12:35
  • On changing the limit, WordPress can only modify the limit if PHP will let it. You could try e.g. var_dump(ini_get_all()['memory_limit']); from inside WordPress somewhere: if the dumped out access value is 4 then no you can't change it.
    – Rup
    Sep 8 at 12:37
  • @TomJNowell It doesn't? I' referring to following article: servebolt.com/help/article/what-is-php-memory-limit/….
    – fischbrot
    Sep 8 at 12:41
  • 2
    If your site uses 250MB to generate a page, and you reduce the memory limit from 300MB to 200MB, you don't magically reduce the memory consumption of your site. Instead your site will hit 200MB and then a PHP fatal will occur when it tries to use 201MB. The memory limit isn't a suggestion, and if a site could use less memory it would do so even if the memory limit is higher because that improves performance. The memory limit is like the execution time limit, it's to stop runaway PHP programs eating all the memory on a server
    – Tom J Nowell
    Sep 8 at 14:17
  • 1
    The solution to your woes is to use less memory, perhaps by doing less stuff, loading fewer things, using more efficient code. This is true wether you change your memory limit or not. Your site uses as much memory as it uses, you can't dictate that it uses less without changing what it's doing.
    – Tom J Nowell
    Sep 8 at 14:20

1 Answer 1

0

So you've tried setting the WP_MEMORY_LIMIT variable in the wp-config.php file, but have you tried .user.ini or .php.ini?

Create one of those files (yes, with the period in front) and then use:

memory_limit=30M

Or whatever value you're looking for. By default, WordPress is set to 40mb for a single installation, and 64mb for a multisite installation.

But as Tom mentioned in the comments, the solution to your problem might not be this. This may lead to server timeouts instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.