Ask your WordPress questions! Pay money and get answers fast! (more info)

PHP Out of memory on Custom Post Type WordPress

  • REFUNDED

I am running WP 3.1 on a media temple shared hosting account and am getting the following error:

<blockquote>Fatal error: Out of memory (allocated 79429632) (tried to allocate 72 bytes) in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-includes/meta.php on line 341</blockquote>

or, today it reads:

<blockquote>Fatal error: Out of memory (allocated 77070336) (tried to allocate 64 bytes) in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-includes/wp-db.php on line 1400</blockquote>

The error only appears when trying to access the following Edit page of wp-admin for a Custom Post Type: /wp-admin/edit.php?post_type=destinations

The problem doesn't arise anywhere else on the site nor admin area and we have about 6 or 7 other custom post types.

There are 753 records in the database for this custom post type.

I have increased the memory limit in the PHP ini file to 99M but still getting the error. I have checked and the wp-admin folder does have the 99M memory limit assigned to it.

99M should be enough, surely?

My host has just replied and say that
<blockquote>If your scripts require more than 99MB worth of memory, you will need to move over to one of our (dv) Dedicated-Virtual Servers</blockquote>
I find it difficult to believe that our site is currently 'too big' to be supported by our current shared host service.

Why doesn't this error show when trying to edit other custom post types?

The active plugins I have are:

Admin Menu Editor
Akismet
All in One SEO Pack
BackupBuddy
Branded Login Screen
Custom Post Type UI
Gravity Forms
Gravity Forms + Custom Post Types
Magic-fields
Math Comment Spam Protection
Profile Builder
Regenerate Thumbnails
Register Plus Redux
Simple Facebook Connect
Shopp
WP-PageNavi
WP Hide Dashboard

Answers (9)

2011-06-15

Peter Michael answers:

Code of your post type? Post here or via PM.


Matt Heyes comments:

I'm using the Custom Post Type UI plugin to create the Custom Post Types and Custom Taxonomies.


Peter Michael comments:

Can't help with that, sorry.

2011-06-15

Maor Barazany answers:

First, try to deactivate all plugins and see if the problem still exist.
If yes, there might be something wrong with your post_type registration, paste the code you use to register it for checking..


Maor Barazany comments:

It might be that the Custom Post Type UI plugin causing this error.
Do you have other post type you created with this plugins? Are they working well with no error message?


Matt Heyes comments:

Yes I have 6 other custom post types all working well with the same setup settings. The code Custom Post Types UI kicks out is:

register_post_type('destinations', array( 'label' => 'Destinations','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => true,'rewrite' => array('slug' => ''),'query_var' => true,'has_archive' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'labels' => array (
'name' => 'Destinations',
'singular_name' => 'Destination',
'menu_name' => 'Destinations',
'add_new' => 'Add Destination',
'add_new_item' => 'Add New Destination',
'edit' => 'Edit',
'edit_item' => 'Edit Destination',
'new_item' => 'New Destination',
'view' => 'View Destination',
'view_item' => 'View Destination',
'search_items' => 'Search Destinations',
'not_found' => 'No Destinations Found',
'not_found_in_trash' => 'No Destinations Found in Trash',
'parent' => 'Parent Destination',
),) );

2011-06-15

Marko Nikolic answers:

Hello,

take a look at last post from [[LINK href="http://wordpress.org/support/topic/fatal-error-out-of-memory-6"]]here[[/LINK]]

Let me know if that fixed your problem. If does, you should decrease offered price.


Matt Heyes comments:

Thanks Marko. I have read through that post but I do not think that is it. The php ini and wp-config file are both defining the memory limit as 99M. I have uploaded a php file to the wp-admin area with:

echo ini_get('memory_limit');

...to see what is going on. It prints out 99M.

2011-06-15

Christianto answers:

Hi Matt,

Did you create a form with Gravity Form and map the custom post type with Gravity Forms + Custom Post Types plugin?
Try to Deactivate Gravity Forms + Custom Post Types.


Matt Heyes comments:

Yes I have a number of forms all mapped with the 'Gravity Forms + Custom Post Types' plugin. I have tried to deactivate this plugin but the problem still exists.


Christianto comments:

Matt,

Deactivate all plugin excluding Custom Post Type UI, and activate plugin one by one and run a test to see what plugin that cause the issue..


Matt Heyes comments:

OK, we have some progress. I have deactivated all the plugins excluding Custom Post Type UI individually and tested after each. This alone has not affected anything.

HOWEVER, I have now deactivated a small handful of plugins and this appears to have freed-up enough memory to allow the Edit Destinations Posts page to load.

There seems to be no logic in which plugins area active / deactive, there just needs to be enough to free-up memory.

Does this makes sense? Seems odd to me really.

I have deactivated Admin Menu Editor and BackupBuddy. Both need to be deactivated for the error to stop.

I would like to have BackupBuddy active though. Any thoughts on how I can make this possible?


Christianto comments:

Matt,

Its not about how many plugin that activated, but more about plugin compatibility and plugin conflict.

Since the BackupBuddy is commercial plugin I guess you can talk with the developer.

Maybe you can try to deactivate Custom Post Type UI plugin and activate both Admin Menu Editor and BackupBuddy. And then register the custom post type manually in functions.php, register also the taxonomy if you create it one that u use for the custom post type.

the drawback is you have to do it manually for all custom post type that you register using the plugin, I don't know if this will run smoothly since all custom post type are registered using plugin..

function destination_init(){
// post type
$labels = array(
'name' => 'Destinations',
'singular_name' => 'Destination',
'add_new' => 'Add Destination',
'add_new_item' => 'Add New Destination',
'edit' => 'Edit',
'edit_item' => 'Edit Destination',
'new_item' => 'New Destination',
'view_item' => 'View Destination',
'search_items' => 'Search Destinations',
'not_found' => 'No Destinations Found',
'not_found_in_trash' => 'No Destinations Found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Destinations'
);
$args = array(
'label' => 'Destinations',
'labels' => $labels,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => true,
'rewrite' => array('slug' => ''),
'hierarchical' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'),
//'taxonomies' => array('destinations')
);
register_post_type('destinations',$args);

// taxonomy example
// uncomment if needed
/*
$labels = array(
'name' => 'Destinations',
'singular_name' => 'Destination Category',
'search_items' => __( 'Destination Categories' ),
'all_items' => __( 'All Destination Categories' ),
'parent_item' => __( 'Parent Destination Category' ),
'parent_item_colon' => __( 'Parent Destination Category:' ),
'edit_item' => __( 'Edit Destination Category' ),
'update_item' => __( 'Update Destination Category' ),
'add_new_item' => __( 'Add New Destination Category' ),
'new_item_name' => __( 'New Destination Category Name' ),
'menu_name' => __( 'Categories' )
);

register_taxonomy(
'destinations',
array('destinations'),
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
)
);
*/
}
add_action('init', 'destination_init');


Hope this help..


Matt Heyes comments:

I have now deactivated the Custom Post Types UI plugin and registered all post types and taxonomies via the functions.php file. All other plugins are now back on.

On accessing the Edit Destinations custom post page I get;

<blockquote>
Fatal error: Out of memory (allocated 77070336) (tried to allocate 80 bytes) in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-includes/wp-db.php on line 1400</blockquote>


Christianto comments:

That means between Admin Menu Editor plugin and BackupBuddy plugin that cause the problem, not because custom post type register using Custom Post Types UI plugin.

You can enable WP_DEBUG by set it to true in wp-config.php like Baki Goxhaj said.
define('WP_DEBUG', true);


Matt Heyes comments:

This doesn't make sense. I have now activated the Admin Menu Editor plugin and the Backup Buddy plugin.

The error returns.

Then if I instead deactivate the Shopp and WP-PageNavi plugin then the Edit page in question works fine and works quickly.

I can't help but feel there is not an error or conflict in any of the plugins at all. Simply with too many items added to the menu in WP-admin it struggles to load. Even with 99M memory limit it cannot load.


Christianto comments:

I dont realize that you use a eCommerce plugin, shopp..
Some of web hosting not suitable for large e-commerce site..

But the odd thing is the error only appear when you want to edit custom post type destinations not on other post type, the error should appear when you want to edit other custom post type..

sorry I really don't know the solution..
You may need a dedicated server or move to other hosting, but I don't know if this will fix your problem..

regards,
Christianto


Christianto comments:

Maybe someone else can help you, just keep this question open...

:D

2011-06-15

Baki Goxhaj answers:

First thing you need to do is go to wp-config.php and set WP_DEDBUG constat to true. That will than allow you to see where your scripts fails. One of your scripts/plugins has so many errors and eats so much memory that you end up with an fatal error. That's where to start.


Matt Heyes comments:

Thanks for your suggestion Baki. With DEBUG mode on and visiting edit.php?post_type=destinations I get the following errors:

<blockquote>
Notice: Undefined index: aiosp_enabled in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766

Notice: Undefined index: aiosp_enabled in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766

Fatal error: Out of memory (allocated 77070336) (tried to allocate 80 bytes) in /nfs/c08/h04/mnt/124794/domains/eguidetravel.com/html/wp-includes/wp-db.php on line 1400</blockquote>

I can deactivate All in one SEO plugin but still get the Out of memory error.


Baki Goxhaj comments:

See what errors/warnings/notices you get when you visit the front page and several other pages.

2011-06-15

Just Me answers:

Set memory to 128MB that is not uncommon for WordPress.

If you want to investigate further did you try to delete and recreate the destination post type?

2011-06-16

Marcel Bootsman answers:

Add this in your .htaccess

php_value memory_limit 128M

(works only if supported by your hosting company)

2011-06-16

Jarret Minkler answers:

Can you dump all the queries that are being run as well?

You mention that you have 700+ posts for this type, usually each post require 3-5 queries, especially when editing.

Am betting its trying to build some huge useless array somewhere


This is what I have at line 14000

function get_results( $query = null, $output = OBJECT ) {
$this->func_call = "\$db->get_results(\"$query\", $output)";

if ( $query )
$this->query( $query );
else
return null;

$new_array = array();
if ( $output == OBJECT ) {
// Return an integer-keyed array of row objects
1400-->>> return $this->last_result;

So looks like you are returning a very LARGE array from a call to get_results() function ..

Possible you may need to run a stack trace at this point in the code to see which plugin is calling this and with what query.


try logging it by adding this code

error_log($this->func_call, 3, '/tmp/error.log');


2011-06-17

AdamGold answers:

Hey, please try this tutorial:
[[LINK href="http://www.wordimpressed.com/wordpress/how-to-easily-increase-wordpress-and-phps-memory-limit/"]]http://www.wordimpressed.com/wordpress/how-to-easily-increase-wordpress-and-phps-memory-limit/[[/LINK]]