Out of memory error uploading images in wordpress - php

I'm having some problems uploading images in WordPress.
The images them selves are around 1-2mb and width/height is quite big 1000px+ X 1000px+ but the client wants to be able to upload them and let WordPress do the re-sizing.
However when trying to upload I'm getting the following error:
"Fatal error: Out of memory (allocated 28573696) (tried to allocate 4096 bytes)"
Now I understand that this means the server doesn't have enough memory to process the image but when I do a phpinfo() check on the server it tells me that I have 256M of memory.
So why would I be getting a fatal error message saying I'm only allocated 32M?
The website itself is hosted by someone else so I don't have access to a php.ini or any of the error logs.
Thanks In advance,
Mark,

Even with a very high memory limit, GD will run out of memory processing a full-size photo from a mid-level digital camera. If your server has ImageMagick on the command line, you could use that. When ImageMagick resizes an image it uses a relatively small amount of memory and it is not subject to the PHP memory limit.
I found a WordPress plugin called ImageMagick Engine that claims to make WordPress use ImageMagick instead of GD. I've never used that plugin myself though.

phpinfo may be showing you memory for the php config for the whole server rather then the shared account you are using. You may not be able to override with your own php.ini due to the main php config file restricting use of php.ini files.
Try adding the 'define" line below to wp-config.php a few lines of white space below the opening <?php in the file:
define('WP_MEMORY_LIMIT', '64M');
This may be able to override shared settings to give you more memory.

Turned out to be an issue with the company hosting the site limiting the memory allocated. Moved to a new host and the problem was sorted.

Related

Fatal error in WordPress, "Allowed memory size of X bytes exhausted"

I am a WordPress beginner and I have only rudimentary knowledge about CSS and HTML. I have built a WordPress blog in the last days, and it was working well. But since two days I couldn't login and couldn't open the page (but I haven't touch the page since about one week, I don't know what happened). This is what was shown:
Fatal error: Allowed memory size of 50331648 bytes exhausted (tried to allocate 30720 bytes) in /home/u0087038969/public_html/wp-admin/includes/deprecated.php on line 533
I suggested that one of the installed plugins caused this trouble. That's why I changed the name of the plugin file via FileZilla, so that I get access to WordPress again. Then I tried to reactivate the plugins gradually to find the trouble-maker. Still it's not really working. What can I do to go about solving the problem?
p.s. I used the following wp plugins: mail poet, all in one seo and contact form 7.
The problem is your installation is requiring more memory than you have available for your site. If you are using a shared hosting environment, you might be at a loss in increasing your memory allotment.
Try updating your wp-config file:
define('WP_MEMORY_LIMIT', '256MB');
If you can change your PHP.ini file you can adjust this:
php_value memory_limit 256MB
Your host seems to have this set incredibly low if it's giving you a memory error at 50MB.

Laravel Memory: 'out of memory (allocated 262144)'

I'm a system administrator which handles a server that hosts an internal api created using Laravel 5. The data source is a SQL Server hosted on another server and the api is used in a IOS app for mobile phones. When the developers created the api, this error was not present and no other memory errors were found. When we went live this error has been popping up from time to time.
[2015-06-01 23:01:52] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Out of memory (allocated 262144) (tried to allocate 140189808036120 bytes)' in Unknown:0
I checked RAM, CPU, swap etc etc of the server but everything was ok. Not much of the resources are being consumed. I've checked PHP Memory limit from php.ini and is set to -1 which is the max according to PHP. I've checked it on CLI, phpinfo.php and httpd.conf I don't see anything wrong. The team tried following this link Allowed memory size of X bytes exhausted
This is a problem in the ios app because the app searches for a correct return code but when this error comes out, even if the ios app transaction is correct, it returns an error because the return code is incorrect as it is returning the code for the memory error.
The first thing I could think of was to restart the Apache httpd service. This immediately solved the issue. but I knew this is not a permanent fix for the issue. When I researched further, I got to know that the error comes when certain PHP scripts require more memory than PHP was allowed by default.
So the solution is to increase the memory allocated for PHP. How to do that? There are 4 possible ways –
Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini
Open the php.ini file in a text editor like TextPad (not in Notepad) and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.
In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after ini_set(’memory_limit’, ‘12M’);
You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M
Or else, Try adding this line to your php file:
Increasing memory allocated to PHP
ini_set(“memory_limit”,”16M“);

Fatal error trying to allocate memory when creating thumbs

I want to share something that happened to me on the way.
I uploaded an image to my website and after that I created some thumbs. Those thumbs where being cropped automatically from relatively big files (jpeg images of about 5mb), and I was doing that lots of times. Suddenly, when uploading a big file and doing a thumb from a cropped image (not the original), I found out this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 22464 bytes)
How could I exhaust 128Mb of memory?
The main problem was I was using more memory than the available. The first thing to check was, of course, if I was uploading a correct file and not one too big. Ok, 3Mb. Then, which was the problem?
Normally, this kind of error comes with the exact line where it completely depletes your available memory. In my case, was inside this one:
$orig = imagecreatefromjpeg($fullPathFilename);
So, the server crashed when allocating a new image into memory. And then, this came to my mind: I didn't free any of the previous allocation calls! As aforementioned, I happened to generate lots of thumbs from multiple sized images. And silly me, I didn't free any of those. So, if you happen to see this error when you crop/resize/alter multiple images, check for this call inside your code:
imagedestroy($orig);
So, to sum up.
If you don't find the imagedestroy() function, then you may have found your problem!
I have also encounted with this problem
Increase the following variables so that your page execution will not stop:
max_input_time
memory_limit
max_execution_time
Cheers

imagecreatefrompng() and size limitation

I have some troubles with the function imagecreatefrompng(), in PHP.
I develop a website which has the goal to permit users to upload their own Sprite Comics (kinds of Comics made with ressources extracted from videogames, called sprites).
I want to display in their galeries some miniatures of their comics, so I use GD and, of course, imagecreatefrompng().
But it throw a fatal error with large images:
Fatal error: Out of memory (allocated 8388608) (tried to allocate
4545600 bytes)
The same error occurs even after setting the value of "memory_limit" via ini_set()...
After few hours of researches, it seems to be because of the resolution: imagecreatefrompng() can't manage images having more than 1 040 000 pixels...!
It's very very inconvenient, since I can't limit the size of comics sent by the users...
Do you know any tips to resolve this issue?
Thnaks in advance!
You need to ask your hosting provider to set more virtual memory. It's a setting in php.ini - memory_limit and shouldn't be problem to do it free. You are now on the most lowest value.

wordpress Fatal error: Out of memory

I have set php memory limit from whm to 256M from WHM > PHP Configuration Editor.
Even so, my wordpress website and admin is showing me an error like below.
Fatal error: Out of memory (allocated 36175872) (tried to allocate 30720 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 14272
Fatal error: Out of memory (allocated 35127296) (tried to allocate 1966080 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 5427
I also tried to add following line to the top of wp-config.php, but no luck and same error.
define('WP_MEMORY_LIMIT', '128M');
can anyone suggest me or tell me what may be the solution?
I finally think I've solved the White Screen of Death from PHP out of memory Fatal Errors.
Full details here: http://www.isthisyourhomework.com/how-to-fix-the-wordpress-white-screen-of-death/
If setting the WordPress and PHP memory limits doesn't work for you, try adding/edditing the following line in either your Apache conf files. I didn't have access to those, so I added the following line to the .htaccess file in my WP server's document root:
RLimitMEM max
Many hosts have set limits on each user on shared-use servers. The above setting will unfetter your server and banish the WSOD.
The SimplePie people reckon that this is caused by a bug in PHP. It was fixed in PHP version 5.3. Upgrading might help.
Newer versions of SimplePie use less memory but still suffer from the same PHP bug that causes lots of cached items to cause you to use loads of memory.
Did you change the memory limit in php.ini(or through WHM service configuration page)? If so, try rebooting Apache

Categories