[wp-hackers] Memory size error when uploading images

Otto otto at ottodestruct.com
Tue Mar 8 17:10:38 UTC 2011


The resolution of the images matters. For the resizing process, the
image has to be expanded to full size in memory. So a 8 megapixel
image will take up around 32 megabytes of memory (32 bit color = 4
bytes per pixel).

This is why increasing the PHP memory limit is a good idea, because
while WordPress quite comfortably runs in around ~20 meg of memory
usually, for certain operations it can need a lot more.

-Otto



On Tue, Mar 8, 2011 at 10:32 AM, Christian Gundersson
<christian at buro2.se> wrote:
> Well, this issue get weirder still.
>
> I tried using different images (same size) and they work, but not the
> original images I tried with. Everytime I try I get the same issue as
> before.
>
> Previously uploaded images (from january and beyond) work flawlessly in the
> Media Gallery with all sizes represented, and all new images as well, exept
> for the two images that cause the problem.
>
> I'll try again with uploading the "problem" images but with a very small
> size just to test.
>
> (On a side note. The Web host limits all PHP scripts to 32MB by default.)
>
> Regards
> //Christian, Büro 2
>
>
>
>
> 2011/3/8 Adam Backstrom <adam at sixohthree.com>
>
>> PHP was trying to allocate an *additional* 5004 bytes, which pushed it
>> over the limit of 33554432 bytes.
>>
>> On Wed, Mar 2, 2011 at 12:28, Christian Gundersson <christian at buro2.se>wrote:
>>
>>> Hi!
>>>
>>> I have a problem and can't seem to get the suggested solutions from the
>>> internets to work. Anyone got a hint I'll be glad to listen...
>>>
>>> I get the error below when I upload an image through the media library
>>> (either directly or from within a post).
>>>
>>> *Fatal error*: Allowed memory size of 33554432 bytes exhausted (tried to
>>> allocate 5004 bytes) in *wp-includes/media.php* on line *254*
>>> *
>>> *
>>> A very weird message since it tries to allocate a smaller amount than the
>>> limit, but anyhew.
>>> *
>>> *
>>> I've looked in the wp_postmeta table after uploading an image and the
>>> entry
>>> for _wp_attached_file is there and looking as it should. However, the
>>> accompanying entry for _wp_attachment_metadata is missing. It feels as
>>> though the upload procedure fails somehow but the image still gets
>>> uploaded.
>>>
>>> The codeline mentioned in the error message is
>>> $image = imagecreatefromstring( file_get_contents( $file ) );
>>>
>>> I can see the image in the media library and I can also attach it to
>>> posts,
>>> but only in it's full size. Previously uploaded images work like they
>>> should, and between the last uploaded image that works and now the only
>>> change is a WP upgrade from 3.0.3 to 3.1.
>>>
>>> Any hints or pointers as to what could be causing this would be helpful.
>>> The
>>> support forum suggestions are not helping, neither is google...
>>>
>>> I'm running WP 3.1 if it's of any interest. Sorry for the long post.
>>>
>>> Regards
>>> //Christian
>>>
>>> *
>>> *
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>>
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>>
>>
>> --
>> Adam Backstrom
>> adam at sixohthree.com
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list