By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,646 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,646 IT Pros & Developers. It's quick & easy.

help! I'm getting "out of memory" errors when trying to resize an image

P: n/a
I've a jpeg image that is 514k, which doesn't strike me as very large.
Yet I'm running out of error when I try to resize it:

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
allocate 12288 bytes) in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageToSquare.php
on line 82
How can I protect against out-of-memory errors?

Aug 17 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Rik
lawrence k wrote:
I've a jpeg image that is 514k, which doesn't strike me as very large.
Well, it is 514K in compacted mode. When creating in image with GD it cen
quickly become very large.
Yet I'm running out of error when I try to resize it:

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
allocate 12288 bytes) in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageT
oSquare.php
on line 82
How can I protect against out-of-memory errors?
Well, you could try to check your usage on various points in the script with
memory_get_usage(), and check what is causing it. You might be able to do things
more effeciently.

Number one protection against out-of-memory errors is descent code, but even
descent code may need more. If you truly need more memory, you should up the
memory limit.

Grtz,
--
Rik Wasmus
Aug 17 '06 #2

P: n/a
.... or just increase the availabe memory:

ini_set('memory-limit', '8M');

Rik wrote:
lawrence k wrote:
>>I've a jpeg image that is 514k, which doesn't strike me as very large.


Well, it is 514K in compacted mode. When creating in image with GD it cen
quickly become very large.

>>Yet I'm running out of error when I try to resize it:

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
allocate 12288 bytes) in

/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageT
oSquare.php
>>on line 82
How can I protect against out-of-memory errors?


Well, you could try to check your usage on various points in the script with
memory_get_usage(), and check what is causing it. You might be able to do things
more effeciently.

Number one protection against out-of-memory errors is descent code, but even
descent code may need more. If you truly need more memory, you should up the
memory limit.

Grtz,

--
--------------------------------------------
m2m server software gmbh - http://www.m2m.at
Aug 18 '06 #3

P: n/a
m2m tech <te**@m2m.atwrites:
... or just increase the availabe memory:

ini_set('memory-limit', '8M');
Please stop topposting. Responses belong below or interspersed with the
original post, because that's how people read: top to bottom.

--
Andrew Poelstra <http://www.wpsoftware.net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
Aug 18 '06 #4

P: n/a
*** lawrence k escribió/wrote (17 Aug 2006 13:46:54 -0700):
I've a jpeg image that is 514k, which doesn't strike me as very large.
JPEG has a very good compression algorithm, like a 10% of original file. So
you can expect the uncompressed file to take 5MB of memory (at a minimum).

You don't say what method you're using, neither paste actual code. But if
your script creates several temp images and loads them all into memory,
that'd be an explanation for running out of memory having 20MB to play
with. Have a look at it and see if you can optimize it. Using more than
20Mb to resize a JPEG is crazy.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.