imagecreatefrompng() and size limitation - php

I have some troubles with the function imagecreatefrompng(), in PHP.
I develop a website which has the goal to permit users to upload their own Sprite Comics (kinds of Comics made with ressources extracted from videogames, called sprites).
I want to display in their galeries some miniatures of their comics, so I use GD and, of course, imagecreatefrompng().
But it throw a fatal error with large images:
Fatal error: Out of memory (allocated 8388608) (tried to allocate
4545600 bytes)
The same error occurs even after setting the value of "memory_limit" via ini_set()...
After few hours of researches, it seems to be because of the resolution: imagecreatefrompng() can't manage images having more than 1 040 000 pixels...!
It's very very inconvenient, since I can't limit the size of comics sent by the users...
Do you know any tips to resolve this issue?
Thnaks in advance!

You need to ask your hosting provider to set more virtual memory. It's a setting in php.ini - memory_limit and shouldn't be problem to do it free. You are now on the most lowest value.

Related

Fatal error in WordPress, "Allowed memory size of X bytes exhausted"

I am a WordPress beginner and I have only rudimentary knowledge about CSS and HTML. I have built a WordPress blog in the last days, and it was working well. But since two days I couldn't login and couldn't open the page (but I haven't touch the page since about one week, I don't know what happened). This is what was shown:
Fatal error: Allowed memory size of 50331648 bytes exhausted (tried to allocate 30720 bytes) in /home/u0087038969/public_html/wp-admin/includes/deprecated.php on line 533
I suggested that one of the installed plugins caused this trouble. That's why I changed the name of the plugin file via FileZilla, so that I get access to WordPress again. Then I tried to reactivate the plugins gradually to find the trouble-maker. Still it's not really working. What can I do to go about solving the problem?
p.s. I used the following wp plugins: mail poet, all in one seo and contact form 7.
The problem is your installation is requiring more memory than you have available for your site. If you are using a shared hosting environment, you might be at a loss in increasing your memory allotment.
Try updating your wp-config file:
define('WP_MEMORY_LIMIT', '256MB');
If you can change your PHP.ini file you can adjust this:
php_value memory_limit 256MB
Your host seems to have this set incredibly low if it's giving you a memory error at 50MB.

Allowed memory size error in Tbs library

Hello i am facing the problem of Allowed memory size error. I have created the project in codeigniter, php and I have used Tbs library. Its worked fine but today it display the error:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 258010 bytes) in
/home/abc/public_html/application/libraries/Tbs.php on line
4222
Please give me any suggestions.
If you are using TBS + OpenTBS in order to merge an XLSX file , then there is a known problem fixed with OpenTBS version 1.9.2 : if the number of row to merge is quite numerous, then you can have a very long process or a memory size error when calling $TBS->Show().
Use OpenTBS 1.9.2 or higher which is optimized for this point, and if the process is still long you can optimize more using the OPENTBS_RELATIVE_CELLS command.
"Allowed memory size of XXXXXX bytes exhausted" is a typical error when you don't have, as it's own name says, enough memory available for the php query to run.
Try upgrading memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.
If this isn't the case, you might have a bug in your software that is causing, i.e. a loop that is consuming memory without any control; but as you have said that it did work before...
Anyway, please check all the other answers from StackOverflow on this aspect:
Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
CodeIgniter Fatal error: Allowed memory size of bytes exhausted
Codeigniter - Allowed memory size exhausted while uploading
Generally this type of occurs when your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and you are creating objects or adding to arrays on each pass of the loop. Check for infinite loops.
If that isn't the problem, try and help out PHP by destroying objects that you are finished with by setting them to null eg. $OldVar = null;.
Check the code where the error actually happens as well. Would you expect that line to be allocating a massive amount of memory? If not, try and figure out what has gone wrong.
Never upgrad memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.Letting application to eat memory he wants to is insane step.Try to find out bug does your application wants that much memory?? Find out

Out of memory error uploading images in wordpress

I'm having some problems uploading images in WordPress.
The images them selves are around 1-2mb and width/height is quite big 1000px+ X 1000px+ but the client wants to be able to upload them and let WordPress do the re-sizing.
However when trying to upload I'm getting the following error:
"Fatal error: Out of memory (allocated 28573696) (tried to allocate 4096 bytes)"
Now I understand that this means the server doesn't have enough memory to process the image but when I do a phpinfo() check on the server it tells me that I have 256M of memory.
So why would I be getting a fatal error message saying I'm only allocated 32M?
The website itself is hosted by someone else so I don't have access to a php.ini or any of the error logs.
Thanks In advance,
Mark,
Even with a very high memory limit, GD will run out of memory processing a full-size photo from a mid-level digital camera. If your server has ImageMagick on the command line, you could use that. When ImageMagick resizes an image it uses a relatively small amount of memory and it is not subject to the PHP memory limit.
I found a WordPress plugin called ImageMagick Engine that claims to make WordPress use ImageMagick instead of GD. I've never used that plugin myself though.
phpinfo may be showing you memory for the php config for the whole server rather then the shared account you are using. You may not be able to override with your own php.ini due to the main php config file restricting use of php.ini files.
Try adding the 'define" line below to wp-config.php a few lines of white space below the opening <?php in the file:
define('WP_MEMORY_LIMIT', '64M');
This may be able to override shared settings to give you more memory.
Turned out to be an issue with the company hosting the site limiting the memory allocated. Moved to a new host and the problem was sorted.

Magento Random Fatal Error

I have a VPS apache server based in a farm.
Recently i sufferd from memory limit errors and i decided to increase the number of the memory limit by changing it in the WHM panel at PHP Configuration to 256MB. after i was presss the button "Save", i got my site (and other wordpress sites i have in my server) all over with random fatal errors and 500 internal server errors on my site: http://amadeus-trade.ru
I can log into the backoffice but, when i tried to go to System -> Configuration i get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#amadeus-trade.ru and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request
And when i try to add products i get this error:
Fatal error: Out of memory (allocated 19922944) (tried to allocate 1245184 bytes) in /home/amadeus/public_html/app/code/core/Zend/Date.php on line 2423
This error allways jumps from file to file and looks like this scheme:
Fatal error: Out of memory (allocated xxxxxxxx) (tried to allocate xxxxxxx bytes) in /home/amadeus/public_html/xxx/xxxx/xxx/xx/xx.php on line xxxx
Now, It is fresh installation. so far (until 01.11.12) the website worked great without problems.
The team in the hosting company says that this is aproblem of a code in magento but i positivly sure that the problem is on the server!
My WHM version was update by the team in 01.11.12 to v11.30
Can you assist me please how to solve this?
Looking at your error message
Fatal error: Out of memory (allocated 19922944) (tried to allocate 1245184 bytes)
in /home/amadeus/public_html/app/code/core/Zend/Date.php on line 2423
PHP is telling you it tried to allocate 1,245,184 bytes of memory, but that was over the limit allowed. It's also telling you there are currently 19,922,944 bytes allocated.
1,245,184 bytes is 1,216 kilobytes (KB), which is 1.1875 megabytes (MB).
19,922,944 bytes is 19,456 kilobytes (KB), which is about 19 megabytes (MB).
This means one of two things.
PHP thinks it's only allowed to allocate around 19 MB of memory
The operating system PHP is running on ran out of memory
Check your runtime php.ini settings to make sure your memory change stuck (use a single page calling the phpinfo function to do this). Also, make sure it's 256M, and not 256MB. The later won't be recognized by PHP, and "weird things" will happen (including a super low memory limit).
That said, my guess is it's the later. When my version of PHP goes over the limit set in the memory_limit ini, I get a slightly different error.
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 10493952 bytes)
PHP is telling me that it's allowed limit has been violated. Your error
Fatal error: Out of memory
Says PHP has literally used up all the memory avaiable to the server at that point in time.
Beyond that, you host's response show a lack of Magento specific knowledge — any host capable of running the system would be able to the give you the information I just did. I'd start by asking them what the maximum memory limit is for a single PHP request. I'd end by moving to a VPS host that advertising Magento capability and has a good reputation for it.
Could it be that 256M was lower than it originally was set to? As it sounds like you already know, Magento requires a minimum of (get this) 256mb of ram, and 512 is recommended, and certainly more for larger applications.
Run a phpinfo() command and see what the memory_limit property is set to. If you can, use your .htaccess to change the limit to a more reasonable level:
php_value memory_limit 512M
However, I must say that there is a good chance that your hosting provider will frown on changing this setting (if they don't allow you to do it in .htaccess).

Fatal error trying to allocate memory when creating thumbs

I want to share something that happened to me on the way.
I uploaded an image to my website and after that I created some thumbs. Those thumbs where being cropped automatically from relatively big files (jpeg images of about 5mb), and I was doing that lots of times. Suddenly, when uploading a big file and doing a thumb from a cropped image (not the original), I found out this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 22464 bytes)
How could I exhaust 128Mb of memory?
The main problem was I was using more memory than the available. The first thing to check was, of course, if I was uploading a correct file and not one too big. Ok, 3Mb. Then, which was the problem?
Normally, this kind of error comes with the exact line where it completely depletes your available memory. In my case, was inside this one:
$orig = imagecreatefromjpeg($fullPathFilename);
So, the server crashed when allocating a new image into memory. And then, this came to my mind: I didn't free any of the previous allocation calls! As aforementioned, I happened to generate lots of thumbs from multiple sized images. And silly me, I didn't free any of those. So, if you happen to see this error when you crop/resize/alter multiple images, check for this call inside your code:
imagedestroy($orig);
So, to sum up.
If you don't find the imagedestroy() function, then you may have found your problem!
I have also encounted with this problem
Increase the following variables so that your page execution will not stop:
max_input_time
memory_limit
max_execution_time
Cheers

Categories