Posted by k4rtik on January 9, 2012 at 5:03pm
I am using the 2.0beta13 version of OpenScholar and facing the following problem:
When I try to upload a profile pic of huge size (2.8 MB in my test) OS gives a blank screen. Apache error log suggests PHP memory limit gets exhausted. Uploading smaller size profile pics seems to work as usual.
I have 128 MB as the set memory limit for PHP, and GD needs about perhaps max of 10 MB of memory for its resize/crop etc. operation. Then what could be the reason for this behavior?
Just to add, I am also hosting a drupal based site and a moodle installation on the same server, but still I don't think 128 MB can be easily exhausted.

Comments
Do you receive and errors in
Do you receive and errors in php's error log? If logging is enabled you should be able to verify the exact fatal that is causing the error and then be able to fix the issue. The file limits imposed by drupal will (should) not cause a white screen.
-RB
Logged errors
I receive no errors in PHP error log, but following in apache's error log (note different memory bytes it tried to allocate):
[Sun Jan 08 14:14:46 2012] [error] [client 192.168.74.103] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 19744465 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 298, referer: http://example.com/site1/node/28/edit?modal&box=site_logo
[Sun Jan 08 14:15:22 2012] [error] [client 192.168.74.103] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12596 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 274, referer: http://example.com/site1/node/28/edit?modal&box=site_logo
[Sun Jan 08 15:16:26 2012] [error] [client 192.168.74.103] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12588 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 274, referer: http://example.com/site1/node/28/edit?modal&box=site_logo
[Mon Jan 09 09:22:16 2012] [error] [client 192.168.74.103] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12588 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 274, referer: http://example.com/site1/node/28/edit?modal&box=site_logo
[Mon Jan 09 09:35:15 2012] [error] [client 192.168.75.242] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 14383969 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 298, referer: http://example.com/kartik/node/1/edit?modal&box=site_logo
Please let me know, if any more diagnostic information is required.
--
K4rtik
Blog: http://k4rtik.wordpress.com
It looks like the memory that
It looks like the memory that php is using plus the memory that GD needs for manipulation is pushing you over the limit. Either you will need to reduce the max file-size or increase the memory limit if you have room.
Not sure
I am not sure if that is the case, 128 MB seems quite a huge amount of memory. I have set the max file size to be 4 MB. Is there any way to check the memory utilization of PHP in this case?
Anyhow I will try testing this after setting a higher memory limit and post the results here.
--
K4rtik
Blog: http://k4rtik.wordpress.com
Increased to 198 MB, still trouble
I increased the PHP memory limit to 198MB, I was able to upload a 2.6 MB image, but testing again with an 3.0 MB image failed.
Is it the GD library which actually tries to take too much space (the log below suggest it needs only 24000 bytes), or there is something else which needs to be looked into?
[Wed Jan 11 11:19:38 2012] [error] [client 192.168.40.69] PHP Fatal error: Allowed memory size of 207618048 bytes exhausted (tried to allocate 24000 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 59, referer: http://example.com/site1/node/1/edit?modal&box=site_logo
[Wed Jan 11 11:20:51 2012] [error] [client 192.168.40.69] PHP Fatal error: Allowed memory size of 207618048 bytes exhausted (tried to allocate 24000 bytes) in /sites/all/modules/contrib/imageapi/imageapi_gd.module on line 59, referer: http://example.com/site1/node/1/edit?modal&box=site_logo
--
K4rtik
Blog: http://k4rtik.wordpress.com
When it says "tried to
When it says "tried to allocate 24000 bytes" it means it was trying to allocate another 24000 bytes. If you look at the number before it says it exausted all of your 198MB. Rendering large images can take a lot of memory, but I don't think it would take that much, but then I don't have a solution for you.
Yes, I completely understand
Yes, I completely understand what it means but the question is where did the 198-128=70 MB of memory go, after I increased the PHP memory limit? Just to add, there is very low traffic on this server, and many people simultaneously uploading, etc. possibilities are ruled out.
Edit: Looking at this http://forums.devshed.com/php-development-5/gd-image-resizing-and-memory..., apparently GD, indeed, needs a lot of memory for image manipulation. For a 3MB image, 50 MB memory usage is normal.
So, I guess either I should reduce the image size limit to 2MB or increase the PHP memory limit to something like 256 MB (and count on my users not to try to exhaust that limit too).
--
K4rtik
Blog: http://k4rtik.wordpress.com
Any chance you ever resolved
Any chance you ever resolved this? I have the exact same problem you describe. memory limit set to 256mb and still I have problems with certain images over 3.5mb
Time-out rather than Excessive File-size
I guess it may not be the problem of over size of the file. As the size is too large, it may cause you time-out.
You may consider trying to temporarily change "max execution time" to zero when you prepare to upload the large file, and restore the value to normal, say 240, upon completion.
I use this method in testing, but not in production.
I'm looking for a solution in
I'm looking for a solution in production, not a temp fix. The site is open to allow registered members to upload large file sizes. I have tested various timeout settings but it did not resolve this (I just tried again to verify).
Configuration of Remote Hosting
I guess you are registered members of certain remote hosting.
I would like to share my experience with you that although I have paid for memberships, it does not mean I am allowed to alter any default AMP settings (e.g. some scripts in htaccess file may not be permitted to override them).
For such kind of reasons, I would contact the hosting provider and ask them whether I could be released.
I hope you can solve your problem very soon.
Please Cast Your Vote to OpenScholar
http://bitnami.com/product/openscholar
I have the same problem. Any
I have the same problem. Any updates? Thanks.