symphonycms / jit_image_manipulation

Just in Time Image Manipulation for Symphony CMS
http://symphonyextensions.com/extensions/jit_image_manipulation/
Other
25 stars 42 forks source link

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 29440 bytes) #133

Closed wdebusschere closed 8 years ago

wdebusschere commented 8 years ago

Uploading image of 3Mb doesn't work anymore.. php.ini: memory_limit = 256 (or -1) doesn't fix it

nitriques commented 8 years ago

memory_limit is for the RAM. It has nothing to do with file uploads.

You need other configs. Make sure post_max_size is always bigger then upload.

memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
nitriques commented 8 years ago

Also, uploads has nothing to with the extension.

If the problem is resizing a 3Mb image, yeah, that has never worked.

wdebusschere commented 8 years ago

Is there solution to resizing a 3MB image?

nitriques commented 8 years ago

Buy a server with more RAM or use cloudinary. I also run a server with a 256Mb limit and it can't handle resizing image larger than 1.5Mb. The best thing to do is to set maximum sizes using image_upload.

wdebusschere commented 8 years ago

Ok, image size is the problem 900kb image with width 7000px also gives the error.

michael-e commented 8 years ago

If the problem is resizing a 3Mb image, yeah, that has never worked.

Are you sure? JIT 1.x works fine for me with much bigger images. The error message in the issue's title suggests that the script tried to allocate more than 134217728 bytes (as mentioned) — that is a 128 MB memory limit, which should not be reached with a 3MB image.

michael-e commented 8 years ago

Ok, I guess that it depends on the physical image size in pixels, i.e. not on the file size?

With 16MB RAM, I can successfully process a 6 Megapixel image. Haven't tested with much bigger images though.

nitriques commented 8 years ago

Ok, I guess that it depends on the physical image size in pixels, i.e. not on the file size?

Exactly. All images becomes bitmaps in memory, and we keep the original and the resized version of those bmps in memory. So yeah, a 3Mb image can eat more than 128Mb

Are you sure? JIT 1.x works fine for me with much bigger images.

Yes. Check http://php.net/manual/en/function.imagecreatetruecolor.php

With 16MB RAM,

it all boils down to memory_limit on a 64Gb server, I still set it to 512M to prevent memory exhaustion.

michael-e commented 8 years ago

Now I tried a really big image: 39 Megapixels (file size: 16MB).

michael-e commented 8 years ago

How can that be???

nitriques commented 8 years ago

Did you turn off the cache before testing ?

nitriques commented 8 years ago
nitriques commented 8 years ago

And what's the destination size ?

nitriques commented 8 years ago

Checking the memory needed before doing the operation would also be wise...

michael-e commented 8 years ago

And what's the destination size ?

The destination size in this test was very small, something like 120 Pixels wide.

michael-e commented 8 years ago

Unfortuantely I can't test too much on this production system, it's the "big one". (I even took all websites down during the tests by setting the memory size too small, hehe...) I don't have any test/development system at the moment.

nitriques commented 8 years ago

very small, something like 120 Pixels wide.

That helps a lot.

Unfortuantely I can't test too much on this production system, it's the "big one"

Stop that! But I am pretty sure you had a cache :P

michael-e commented 8 years ago

I love to work on the production system!

I am pretty sure you had a cache

Well, no. The cache gets purged when "something" is saved — which I did. I often break things. But nobody ever complained, because my "dev outages" never last long, which is so much better than elsewhere on the web. :-)

nitriques commented 8 years ago

Ahaha!

Well I can't explain it with the fact that your thumbnail is kindof small. Mines are often +600px wide

michael-e commented 8 years ago

Nope. I just performed the following extreme test:

It works. :-)

michael-e commented 8 years ago

(Admitted: I had to increase the max. execution time.)

nitriques commented 8 years ago

Wow this is crazy. Which version of PHP + GD do you run ?

michael-e commented 8 years ago
nitriques commented 8 years ago

Ubuntu ?

michael-e commented 8 years ago

Nope, Debian.

nitriques commented 8 years ago

Potato-Tomato ;)

nitriques commented 8 years ago

But that's interesting considering that I may implement the test the memory available before doing the operation thingy.

michael-e commented 8 years ago

Yes. I have no explanation for your issues (resp. my no-issue).

nitriques commented 8 years ago

7f98c78 won't solve this problem, but could reduce the lot on the server. Use with caution.