WordPress Php Fatal Error Out Of Memory

WordPress php fatal error out of memory

I am dealing with a WordPress site that shows regular out of memory errors when navigating the control panel.

I am asking a question about it here because I have tried all the usual options: checking the memory assigned by the server both from the server and via phpinfo, using WP-DEBUG and the Query Monitor plugin. It’s not the theme or the page content, because it’s happening on the admin interface, not the public one.

I would like to know about other issues that might be restricting memory usage that I can investigate this further.

I have define( ‘WP_MAX_MEMORY_LIMIT’, ‘768M’ ); set in wp-config.php a php info check shows the memory limit on the server as 768M. I have checked the server logs, which say the account has come nowhere near its 2Gb account memory limit in the last seven days.

The site is only trying to allocate fairly small amounts of memory : not more than about 25Mb. The errors look like:

PHP Fatal error: Out of memory (allocated 2359296) (tried to allocate 12288 bytes)

PHP Fatal error: Out of memory (allocated 11272192) (tried to allocate 12288 bytes)

That surely should not be a problem on a site with these resources. There’s no consistency on which file or plugin is mentioned in the error log.

And yet, I’m getting these out of memory errors. I don’t know where else to look!

Can anyone suggest what I am missing? I have reworded this question to make it clearer what I have already tried, and explain why I think this question is generally useful.

WordPress php fatal error out of memory

i have a memory issue while NextgenGallery try to create the thumbnails.

Wp-Version is 3.4.1

Fatal error: Out of memory (allocated 29884416) (tried to allocate 2000 bytes) in /xxx/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 179

But my memory is not exceeded: PHP Version : 5.2.17 / 32Bit OS Memory limit : 128 MByte Memory usage : 27.75 MByte

I am getting desperate trying to solve this issue.

Many thanks in advance for any help, Joe

I’m not sure where you’re getting those stats, but I doubt that is showing you the amount of memory being used while processing the images. If you navigate to some memory use screen, you’re seeing the amount of memory currently allocated, which is now an entirely different process from when you were uploading images. The fact that Out of memory (allocated 29884416) is already larger than 27.75 MByte points to this.

this just means you need to make a small change in your .htaccess or create a php.ini to increase the allocated memory for WordPress.

You and your visitors will see this out of memory error when WordPress is trying to process something (in your case the thumbnails).

Try either of these to fix the problem
1. Create a file in your root /WordPress folder called php.ini , add this line in PHP.ini
memory_limit = 64M;
2. If you don’t have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M

You can also try increasing it to 128M or 256M

If that doesn’t work – contact your web host provider for their preferred method.

WordPress php fatal error out of memory

My problems with my site continue. I got timeout errors initially. The server ground to a halt, very high memory use by Apache. Site came back with no pages. I found that deleting the most recent post in wp_posts brought the site back up. Sysadmin pointed out high cpu use by apache but this may be a red herring, the memory not cpu is an issue. It seems that when user uploads a file, the memory used by Apache goes through the roof eventually bringing the site down. The files aren’t that large so it’s not php upload_max_filesize causing it. I suspect the problem is being caused by a plug-in. the plug-ins I have are:

  • contact form 7
  • contact form to db extension
  • enable media replace
  • health check
  • Relevannsi
  • Simple expires
  • User access manager
  • Category posts
  • breadcrumb trail
  • configure SMTP

Does anyone know of any issues with any of these, or does an issue with plug-ins sound like a likely cause? I get Fatal error: out of memory error now. User told me it went when he tried to upload file.

WordPress php fatal error out of memory

I’m getting this nasty error Fatal error: Out of memory (allocated 18087936) (tried to allocate 77824 bytes) . Weird thing is, it’s 17,25 mb (allocated) and it tried to allocate 76 kb. Memory limit is 128MB, and as you can see it’s not even close to that. VPS got

400mb of free ram at that moment. It only happens when I’m posting something and not all the time. I find it weird and don’t really know what can cause it. Let me know if you need any additional info.

The error says that the memory limit is 18M and not 128M. This means that somewhere the memory_limit is set to something different than 128M (local php.ini, or the application itself, since PHP can override this setting at run-time).

I would suggest that you first create a file called (say) phpinfo.php with the following contents:

and place it where your script runs. Then access the file with your browser and look for the actual memory_limit value. If it’s still showing 128M both for "global" and "local" value, then probably somewhere in your code, there’s a "ini_set("memory_limit", $value);" call or something similar. Otherwise, if it says 18M, look for other places where this can be set:

  • Check your wp-config.php file
  • Check for any local php.ini file (look into the phpinfo.php page to see the location of the actual loaded php.ini file)
  • Check for any .htaccess files that contain such a directive

Hope this helps, as I had the same issue:

You’re running into a limitation in WordPress’s own memory limit, not your PHP memory_limit. WordPress implemented this limit in order to prevent poorly written scripts from shutting down your whole PHP interpreter. Unfortunately, as you’ve noticed, it’s rather barebones.

The easiest way I’ve found to fix this is to install the Change Memory Limit plugin from WordPress plugin repository. It allows you to fix the issue without modifying any WP files manually.

The 64M default for the plugin will probably be fine for you.

Alternatively, if you don’t want to trust a third party plugin, add the following line to wp-config.php :

THIS TO BE ENTERED IN THE WP-CONFIG FILE WHICH IS IN THE ROOT OF THE WORDPRESS SETUP: ENTER AFTER : define(‘ABSPATH’, dirname(__FILE__).’/’); THE FOLLOWING:

ALSO CREATE A PHP.INI WHICH SHOULD BE UPLOADED TO THE PLUGIN FOLDER IN WP-CONTENT:

Hope this helps!

Just an option that helped me debugging these errors.

If you have access to the .htaccess, you could try this:

If that doesn’t help, you could try this to check the settings:

I hope this works, for me it did.

I am not sure this causes the error, but it is worth checking for.

Many of the most untraceable pathetic out of memory errors are caused by :

1) User defined exception handlers, causing exceptions therefore recursing.

2) The above + trying to fetch class information of object originating the exception, and the class information testing causes an autoload attempt, in which autoload throws another exception and therefore recursing.

Have you done something conflicting with WP error handling or autoload?

I install wp-memory-usage plugin by alexrabe on all my WordPress sites.

This plugin helps you to see what WordPress is seeing in terms of your PHP memory usage. Other approaches may show you the PHP settings at the server, however these settings are often overridden with various techniques the closer you get to a rendered page within the browser.

To set your max memory -> open your favorite text editor and create a file called php.ini; include in the file the following line:

Place a copy of the php.ini your WordPress root directory. I also place copies in: /wp-admin; /wp-content; and /wp-includes.

Add define(‘WP_MEMORY_LIMIT’, ‘256M’); in your wp-config.php file. Its the easiest way.

It looks as through somewhere in the site, the memory limit is being overwritten, do a site wide search in the code for ini_set(‘memory_limit’ and see what is returned.

Given that your phpinfo() script returns the correct value for memory usage, this is obviously being set in WordPress somewhere, and is therefore overriding the Apache provided values, so using a .htaccess to apply this still won’t work.
This link (http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP) suggests that WordPress does its own memory management by default, so setting the (‘WP_MEMORY_LIMIT’, ‘256M’) in the wp-config.php is logical.

If you have shell access to the server hosting your site I would suggest going to the DocumentRoot of your wordpress install and running the following commands:

This will search through your files for the string 18M (the value your memory limit seems to be set to in human readable terms) and the configuration options for the WordPress defined memory limit. I suspect that one of these commands will return positive output. You should then change the WP_MEMORY_LIMIT as suggested (although 256M may be a little high – try 64M initially, you don’t want to cause yourself potential problems).

WordPress.org

Support » Fixing WordPress » PHP Fatal Error: Out of memory

PHP Fatal Error: Out of memory

I’am new here in WordPress:) And it is very cool that WordPress has this kind of forum to help each other!

Ok, I have a problem with our intra installed on Xampp/Wordpress 4.9.4 and PHP Version: 7.2.0.

The problem is that we get 1-3 times a week this error:

Fatal error: Out of memory (allocated 6291456) (tried to allocate 65536 bytes) in D:\xampp\htdocs\xxx\wp-includes\meta.php on line 868

Fatal error: Out of memory (allocated 6291456) (tried to allocate 65536 bytes) in Unknown on line 0

Every time plugin / file paths are different.

We have done these things:

php.ini
– memory_limit = 512M
– max_input_vars: 2000
– max_execution_time: 60
– upload_max_filesize: 8M

wp-config.php
– define ( ‘WP_MEMORY_LIMIT’, ‘512M’ );

But no effect on error. It still comes time or another.

Memory Usage: 6M (1%) of 512M.

So if somebody can help me, it would be very very kind thing because we do not know anymore what to do.

Leave a Reply

Your email address will not be published. Required fields are marked *