I have a script that takes an uploaded photo, resizes it to create a thumbnail and also resizes the original photo to fit into max dimensions.
When I upload a photo of about 2MB, I get an oom error. Something to the effect of "...failed to allocate xxx bytes...".
I had ini_set("memory_limit","20M");
When I increased this to 32M, the error disappeared, so I assume that the script used more than 20MB but less than 32MB.
I take the usual precautions, like destroying every image after it's created.
Is it normal for scripts that use the GD library to consume such large amounts of memory?
Normal for image manipulation script to use more than 20MB?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
raw images stored in memory can easily take up a lot of space. Considering the compression involved in most images, fully decompressed and allocated a simple 2MB JPEG can balloon to very large sizes.. figure at least 4 bytes for every pixel... plus some added stuff like round up the scan line length to the nearest multiple of 4...
what's the dimensions of this image?
what's the dimensions of this image?
Thanks for the tip. Will do.
I was sucked-in to moving to a new host by the lure of the Zend Suite + virtual hosting on a segmented portion of a server. Not a true dedicated host, but an "appliance server" where I could put all my various sites.
I had put so much work into these scripts, that I didn't feel "safe" to be in a shared environment any longer.
Well, it turns out that it may have been a mistake, since customer service response times at this new company are measured in days. And I'm not even mentioning their reluctance to upgrading from MySQL 3.23. Yeah, what?!
My next move is going to be migrating to a server at home or office.
I was sucked-in to moving to a new host by the lure of the Zend Suite + virtual hosting on a segmented portion of a server. Not a true dedicated host, but an "appliance server" where I could put all my various sites.
I had put so much work into these scripts, that I didn't feel "safe" to be in a shared environment any longer.
Well, it turns out that it may have been a mistake, since customer service response times at this new company are measured in days. And I'm not even mentioning their reluctance to upgrading from MySQL 3.23. Yeah, what?!
My next move is going to be migrating to a server at home or office.
-
Jerryscript1
- Forum Newbie
- Posts: 10
- Joined: Thu Jan 27, 2005 4:22 am
- Location: Las Vegas