admin管理员组

文章数量:1122846

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.

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.

Share Improve this question asked Sep 8, 2022 at 12:24 fischbrotfischbrot 11 bronze badge 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 Commented Sep 8, 2022 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 Commented Sep 8, 2022 at 12:37
  • @TomJNowell It doesn't? I' referring to following article: servebolt.com/help/article/what-is-php-memory-limit/…. – fischbrot Commented Sep 8, 2022 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 Commented Sep 8, 2022 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 Commented Sep 8, 2022 at 14:20
 |  Show 2 more comments

1 Answer 1

Reset to default 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.

本文标签: phpChanging WPMEMORYLIMIT doesn39t affect actual memory limit