Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes

What's the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

WordPress tells us: the WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary in the event you receive a message ...
DaveLak's user avatar
  • 1,037
13 votes
Accepted

Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails

I have checked your code, and I think you are missing the guid of the images. Please have a look at the code below: $post_id = 1234; $images = array('filename1.png', 'filename2.png', ... 'filename10....
Syed Fakhar Abbas's user avatar
8 votes
Accepted

WP_MEMORY_LIMIT didn't work in wp-config

Need to set both the constants before ABSPATH is defined. Right after this line in wp-config.php define( 'WP_DEBUG_LOG', true );
Piyush Rawat's user avatar
7 votes

What's the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

The WP_MEMORY_LIMIT is the default limit set in the front-end, but it can be raised up to WP_MAX_MEMORY_LIMIT in wp-admin pages, as well as certain other functions such as image manipulation. In ...
joetek's user avatar
  • 323
7 votes

Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)

Ater months of searching I stubmled upon this https://bugs.php.net/bug.php?id=72451 The bug is resolved in PHP 7.1.
ScottB's user avatar
  • 131
5 votes
Accepted

How can I free up the memory used by update_post_meta?

It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time update_post_meta ran, Query Monitor would store some data about the query, which eventually added ...
Pikamander2's user avatar
4 votes

Wordpress media upload limit?

Three things you need to check. upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file exactly. All of these three settings limit the maximum size of data that can be ...
prosti's user avatar
  • 4,283
4 votes
Accepted

Are there individual memory allocations for different user roles in WordPress?

Because of this line in wp-admin/admin.php: if ( current_user_can( 'manage_options' ) ) { wp_raise_memory_limit( 'admin' ); } In other words, WordPress raises the memory limit to ...
TheDeadMedic's user avatar
  • 36.4k
3 votes

WP_MEMORY_LIMIT didn't work in wp-config

This is because you should define the above before /* That's all, stop editing! Happy blogging. */ Like this: define('WP_MEMORY_LIMIT', '256M'); define('WP_MAX_MEMORY_LIMIT', '512M'); /* That's ...
Drupalizeme's user avatar
  • 1,616
2 votes
Accepted

Mass importing json data into custom fields (postmeta)

Just adding this for posterity in case anyone else comes across this. The issue is indeed with ACF which adds inserts two rows into the the database. meta_key | meta_value {$field_name} | $...
mantis's user avatar
  • 780
2 votes

Mass importing json data into custom fields (postmeta)

update_field() is ACF function so I would guess the issue is with it. From quick look at source it calls get_field_object() and so on, so environment might not be sufficient for it to work correctly ...
Rarst's user avatar
  • 99.6k
2 votes

Wordpress out of memory allocated issue?

If you are on any environment you did not personally set up, you may not have the permissions to override the php.ini file. Also some plugins can manually do: ini_set( 'memory_limit', '512M');
AndreyP's user avatar
  • 141
2 votes

Set WP_MAX_MEMORY_LIMIT higher than PHP.ini memory_limit

The true maximum is ultimately up to the host - they can impose whatever limits they wish. But even so, you can try with WP_MEMORY_LIMIT, which is the memory limit WordPress sets at runtime for any ...
TheDeadMedic's user avatar
  • 36.4k
2 votes

Wordpress database becoming huge. How to analyze and optimize it? fear of running out of memory

One thing you can do to help reduce the amount of bloat is add a plugin that controls the number of previous revisions kept for Pages, Posts, etc (preferably one that allows for separate values for ...
Scott R. Godin's user avatar
2 votes

WP_Query leaking absurd amounts of memory

Using wp_suspend_cache_addition( true ); at the beginning of the script solved the problem for me.
Moiceanu Marius's user avatar
2 votes
Accepted

Why do get_category_by_slug() crashes WordPress 4.8

Because get_category_by calls get_term_by which calls get_terms which creates a WP_Term_Query which runs the list_terms_exclusions filter, which runs your code that calls get_category_by which calls ...
Tom J Nowell's user avatar
  • 59.4k
2 votes

Defined Wordpress Memory Limit to Unlimited

If you search WP source code, you'll find _MEMORY_LIMIT in wp-includes/default-constants.php $current_limit = @ini_get( 'memory_limit' ); $current_limit_int = wp_convert_hr_to_bytes( $...
David Sword's user avatar
  • 3,327
2 votes
Accepted

WP_MEMORY_LIMIT didn't work in wp-config, only within default-constants.php

Your code appears to be using he incorrect quote characters. You have ’ instead of '. This can happen if you copy it from a site where the quotes have been converted to ‘fancy quotes’ by the ...
Jacob Peattie's user avatar
2 votes

How can I free up the memory used by update_post_meta?

While it is good that you found the specific problem in your setup, the general answer is that you are doing it wrong. Every time that you are doing anything which requires many DB operations you are ...
Mark Kaplun's user avatar
  • 23.4k
1 vote

How to display or print WordPress memory limit and WordPress max memory limit

Resolved via this functions as suggested by Rup wp_is_ini_value_changeable( 'memory_limit' ) source link
chinazaike's user avatar
1 vote
Accepted

Exec wp query in slow motion to avoid memory error?

It appears that you're trying to get the latest 15 posts where the meta key is not equal to 'None'. Instead of loading all the posts into memory and then looping through to see if the meta value is ...
Nathan Johnson's user avatar
1 vote

Wordpress Memory limit not increasing

Try to create .user.ini file in root and put below code upload_max_filesize = 500M post_max_size = 256M memory_limit = 500M max_execution_time = 300 max_input_vars = 500M Try and let me know if any ...
Pratik Patel's user avatar
  • 1,099
1 vote
Accepted

Memory Leak in plugin action

Depending on what exactly you're trying to achieve, I agree with Tom's comment, that a WP-CLI command might be better. The advantage is that the command runs from php directly on the server (usually ...
kero's user avatar
  • 6,210
1 vote

PHP Warning: include(): Unable to allocate memory for pool

Does this topic help (it appears to be referencing the items you are looking at currently) https://stackoverflow.com/questions/3723316/what-is-causing-unable-to-allocate-memory-for-pool-in-php ?
Edward Caissie's user avatar
1 vote

Wordpress database becoming huge. How to analyze and optimize it? fear of running out of memory

The thing i do for this to minimize and optimize the database is by adding a two line of code on config.php define('AUTOSAVE_INTERVAL', 300 ); //seconds (default is 60) define('WP_POST_REVISIONS', 5 )...
Aishan's user avatar
  • 762
1 vote

Wordpress media upload limit?

Try to paste this code below in all .htaccess in root of folder : Options -Indexes php_value upload_max_filesize 1000M php_value post_max_size 1000M php_value max_execution_time 300 ...
user111587's user avatar
1 vote

Wordpress "Allowed memory size" on wp-db.php

You need to increase the php-memory-limit you can find out how much you have now with <?php phpinfo(); ?> Edit php.ini .Search "memory_limit" in your php.ini, and change the value of it. If no "...
Cristian Mergea's user avatar
1 vote

What is the difference in the WP memory limits?

Technically, they are for only one purpose: override memory_limit value in php.ini. The difference is: WP_MEMORY_LIMIT will permanently override memory_limit if its value is greater than the current ...
user6454281's user avatar
1 vote

What is the difference in the WP memory limits?

Max is used on the admin side, WP_MEMORY_LIMIT is used on the front end. Don't increase the memory available more than you need to or you'll run the risk of running out of RAM if you have too many ...
Andy Macaulay-Brook's user avatar
1 vote

How can Wordpress be made more memory efficient?

I highly recommend Wordpress on PHP 7. You will be amazed by the performance improvement and memory efficiency. Aaron Jorbin stated "2-3x speed improvement compared to PHP5.6".
ManoCarayannis's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible