why is this php fatal error message showing? - php

I'm a novice PHP programmer and not so knowledgeable abouts bits and bytes, and I was wondering why this message even shows up:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40 bytes) in D:\xampp1.8.3\htdocs\hkmschat\default.php on line 227
I know my website is very large, but it loads fast enough, and it would be a pain to change it.
I was wondering, why is allocating 40 bytes too much when the allowed memory size is 134217728 bytes (128 megabytes). Can somebody help me with the meaning of "the allowed memory size" and "allocated memory". Again, I don't know much about these.
I've also changed php.ini's memory_limit value to "256M", but it didn't work then. the error just changed to
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 40 bytes) in D:\xampp1.8.3\htdocs\hkmschat\default.php on line 227
Can somebody please inform me on what I'm missing?
Thanks in advance.

It's not trying to JUST allocate 40 bytes. You already have 128Megs of stuff loaded into memory, and it is trying to then load 40 bytes more. This puts you over the limit, and you get the fatal error. As for the php.ini, there are several versions of php.ini that could be being used. you should use a test page and use a phpinfo(); call to determine that you are modifying the correct php.ini.

Related

PHP Fatal Error when searching a query that returns no results (Woocommerce Blank page of death)

I have a woocommerce shop where the archive-products.php template comes up blank (only loads the header) whenever I search a query I know will return no results.
I turned the log on and came up with these two lines:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 249
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 3854336 bytes) in /var/www/html/wp-includes/functions.php on line 4344
I replicated it multiple times and it throws the same error all the time, besides one time that the error came up as:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 155648 bytes) in Unknown on line 0
On my development enviroment these files are the same, but the error only happens on my production enviroment , so I am wondering if this is actually a memory issue or maybe something else, has anyone come up with this issue before?
UPDATE:
So I narrowed the issue down to the call of wc_get_template( ) inside of wc_no_products_found() , im not sure how it works but it seems to be having issues when trying to call the no-products-found.php file (which does exist on the woocommerce plugin folder)
edit your PHP.ini file. Simply increase the default value
find and change this
memory_limit = 128M
to
memory_limit = 256M
now it should work

session_start() - cause E_ERROR - Allowed memory size of 134217728 bytes exhausted

In one of application that I maintenance (PHP based) I got the E_ERROR which is connected to the memory - "Allowed memory size of 134217728 bytes exhausted...".
I am familiar with temporary solutions like setting up higher amount of memory for the script etc. but it is just temporary solution and here I need to solve it from the roots.
I have checked amount of memory which is used after each part of code in my script by simply writing it to the log file like:
addMsg('1 - Memory Usage: ' . (memory_get_usage()/1048576) . ' MB \n');
By this method I have found out that only one simple line of code increase drastically memory usage and it is: session_start() function, which then causes this error.
Interesting thing is that this error does not occur every time scripts loads. It occurs from time to time (based on high traffic on that app, it occurs every few minutes). Also, I have found out about this error from New Relic which I use for monitoring and from logs. Although, I have never experienced myself.
Does anybody have any theoretical idea how this simple function can cause such memory usage that it cause E_ERROR?
Also, all of my errors look something like this:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 10556354 bytes) in Unknown on line 0
Allowed memory size of 134217728 bytes exhausted (tried to allocate 10399243 bytes) in Unknown on line 0
Allowed memory size of 134217728 bytes exhausted (tried to allocate 8112988 bytes) in Unknown on line 0
From my point of view, it seems that script wanted to allocate less space than it was allowed and even that, error occurred. Am I right or something else is going on?

why does the ini_set('memory_limit') doesn't work?

I am doing a file resizer feature, and when I use very high resolution images, I get this fatal error:
PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 8884 bytes) in /path/resizer.php on line 35
(resizer.php is the resizer class)
Then, when I use ini_set('memory_limit', '64MB');
.. in front of the whole block: if (isset($_FILES....))
... And i get this fatal error:
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to
allocate 8884 bytes) in path/resizerenter code here.php on line 35
Please note that the allocated memory has decreased while I requested an increase.
Please let me know if you know what is wrong.
Thanks a lot
check the php.ini setting: memory_limit
Maybe is already more than 64M. In case you can
ini_set('memory_limit', '128M'); or 256...
Operations with big images can happen to use huge memory!

Magento trying to allocate excessive amounts of memory

I'm having an issue with my Magento 1.6.1.0 community edition store. It's attempting to allocate roughly half a gigabyte of memory every 15 seconds or so. Unfortunatly the error message isn't very helpful as you can see below:
[29-Mar-2012 07:36:38] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 431187952 bytes) in Unknown on line 0
[29-Mar-2012 07:36:40] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 244111344 bytes) in Unknown on line 0
[29-Mar-2012 07:36:54] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523921392 bytes) in Unknown on line 0
[29-Mar-2012 07:37:07] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 534718448 bytes) in Unknown on line 0
I've spoken to my hosting about this and while they say that the memory limit of 128Mb is a little low for running a full magento store (we intend on upgrading to a more generous package when it's live) these errors suggest something is wrong with Magento rather than the hosting since I'm fairly sure that this is not normal behaviour. I can't change my memory limit from 128Mb on this package.
It continues to happen around the clock even during times when I can be fairly certain nobody is accessing the site at all. This makes me wonder if it's to do with the cron jobs Magento runs.
Does anyone have any tips on how to help track down this issue? Or has anyone run into something similar before?
before installing any kind of software you should overview system requirements:
http://www.magentocommerce.com/system-requirements
and Magento specifically states there
Memory_limit no less than 256Mb (preferably 512)

PHP ini problem

I have this error in a PHP based installation:
Fatal error: Allowed memory size of
8388608 bytes exhausted (tried to
allocate 98304 bytes) in
D:\vertrigo\VertrigoServ\www\dos\ana\libraries\test\domain\query\query.php
on line 804
I changed my php.ini memory_limit from 8MB to 12MB, however I am still receiving the error.
What is the problem?
Fatal error: Allowed memory size of 8388608 bytes exhausted
8 Megabytes sounds pretty low. WordPress for example will choke on anything under 12 MB even without plugins, and run smoothly with 16 MB or more.
I'm therefore going to boldly guess that your social engine simply needs more memory to run. See for example this answer on how to raise the memory limit: Increase PHP Memory limit (Apache, Drupal6)

Categories