473,395 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
4 6915
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
.... 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
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
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: lawrence | last post by:
I'm not sure how this is normally done, on a large site, perhaps one running Phorum. Occassionally a thread will have hundreds of entries, perhaps a meg or two worth of data. You won't necessarily...
12
by: Dave Smithz | last post by:
Hi there, Users of my PHP DB application have complained that it seems to log them out every now and then. I actually assume this is when it has been idle for sometime as I use session variables...
5
by: Eddie | last post by:
I have a MySQL-server running Innodb. We have installed ~ 2GB of memory in the server. In spite of this MySQL keeps crashing due to out-of-memory errors. The server is a dual xeon i686 running...
5
by: redsoxnut | last post by:
Can someone take a look at http://www.grooveswitch.com and help me figure out what's causing the misalignment? I just converted my entire site to a tableless design and am hung up on this final...
1
by: ShikariShambu | last post by:
Hi All, I have a web site that makes calls to components hosted in COM+. Recently we started seeing some out of memory errors on the web site. On further analysis we found that the number of...
7
by: Jeffrey Melloy | last post by:
I have a couple users trying to install Postgres on OS X. To the best of my knowledge, both of them are using 7.4.5/10.3.5, and got identical errors while trying to init the database: Reducing...
1
by: reaway | last post by:
When I call Web Service by mulithread just like the following: public class test { public void Execute() { while(....) { ThreadPool.QueueUserWorkItem(new WaitCallback(DoProcess),request); }
10
by: electrixnow | last post by:
I have the following test code that opens and reads a file. The file is over 19000 lines long. The file contains two fields on each line: "text,text\n" I have placed a test that for loops up to...
4
by: insomninja | last post by:
Consider the following: int* pi = malloc(sizeof(int)); //-- stuff goes here -- pi = realloc(2*sizeof(int)); If realloc fails it will return a null pointer but will it also free the...
4
by: kihjin | last post by:
Hi, this is my first post here. I tried to read the Posting Guidelines but the page was blank. I'll try to use basic common sense, but please forgive (and inform) me if I commit an error in my post....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.