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.
Ater months of searching I stubmled upon this https://bugs.php.net/bug.php?id=72451 The bug is resolved in PHP 7.1.
Your installation might be … less than optimal. Using my Mini Theme, no plugins and the following code on the front page right after the opening body tag … print count( $GLOBALS ) . ‘ $GLOBALS<br>’; print @count( get_defined_vars(), 1 ) . ‘ variables<br>’; print count( get_defined_constants( TRUE )[‘user’] ) . ‘ constants’; … I … Read more
Use the fields argument to grab just the ID – will save you a ton of memory 😉 $product_ids = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => array( ‘product’, ‘product_variation’ ), ‘fields’ => ‘ids’, ) );
The apache process memory amount you talk about (80 to 120 MB per process) can be split into two reasons. Apache WordPress Apache You can optimize apache by only loading the number of modules you need and other optimization tweaks that will reduce the memory. If you have not optimized that yet, give it some … Read more
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 such as “Allowed memory size of xxxxxx bytes exhausted”. Or as the PHP docs put it [A memory limit] helps prevent poorly … Read more
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.png’); // Get the path to the upload directory. $wp_upload_dir = wp_upload_dir(); foreach($images as $name) { $attachment = array( ‘guid’=> $wp_upload_dir[‘url’] . “https://wordpress.stackexchange.com/” … Read more
You can try a trick with querying post data directly and setting filter field of post objects to sample before passing it to get_permalink() to reduce memory usage. See get_permalink memory usage issue for detailed reasoning behind it.
Theoretically, editing your config.php and add this line before wp-settings.php inclusion. define(‘WP_MEMORY_LIMIT’, ‘256M’); should raise your memory limit for WordPress to 256MB or whatever value you set. And this will work sitewide. However, as sorich87 pointed out, there are few functions that will alter this setting with hard coded 256 MB limit. To Hack or … Read more
Excellent responses on WP Hackers: http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213.html What you’re doing with that query, is loading EVERY matching post into memory, including the full post contents. As you can imagine, this is probably quite a lot of items. You can pass ‘fields’ => ‘ids’ into WP_Query to simply return a list of matching post_ids instead, which should … Read more
The problem comes from the fact that, in order to display pages and their hierarchy, WP has to load all of them and then build the tree in memory. So, you are saved if you can convert most of those pages into one or several non-hierarchical custom post types. The permalink structure can be emulated.