Understanding php "Out of memory" error - php

I can find lots of tutorials on how to overcome the out-of-memory error. The solution is: To increase the memory in the php.ini or in the .htaccess - what a surprise...
I actually don't understand the error message:
Fatal error: Out of memory (allocated 32016932) (tried to allocate 25152 bytes)
"Allocated 32016932", means 32MB have been allocated as in - the PHP script is using 32MB? Tried to allocate 25152, means that another 25KB were tried to be allocated, but the script failed as the maximum (of ~ 32MB?) has been reached?
What can I actually tell from this error message, besides that I'm "out of memory"?

I Always interpreted it like:
Fatal error: Out of memory ([currently] allocated 32016932) (tried to allocate [additional] 25152 bytes)
But good Question if there is a bulletproof explanation.

It's exactly like you understood it.
The limit is probably set at 32MB, you have already 32016932 bytes allocated and when php tried to allocate 25152 more bytes, the limit is exceeded thus the error message.
You probably can see the line where the faulty allocation happened in your logs or near the error message on your screen.
Good luck finding the culprit.

Related

Concrete5 PHP GD running out of memory

I ran into this rather annoying issue the other day; when a page tries to load it will just 'stop' half way through returning half a page to the end user. The exact error is shown below.
[03-Jul-2015 03:15:04 Europe/London] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 18996 bytes) in [path]/concrete/vendor/imagine/imagine/lib/Imagine/Gd/Image.php on line 602
I spoke to my host and they bumped up PHP's memory to 512M (which is a bit overkill) yet it still throws this error. I'm not sure if it's a memory leak in Concrete5 somewhere or if it is just the server that the site is hosted on.
Any suggestions are much appreciated.
Edit: Forgot to mention I'm running 1.7.4.2
Edit 2: For reference the exact function is imagecreatetruecolor()
Either:
ini_set('memory_limit','256M');
Inside PHP or getting your host to bump up the memory limit will do the trick.

why is this php fatal error message showing?

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.

PHP Fatal error: Allowed memory size - on a non-existent line

I'm seeing this error in my production server, sometimes (I mean, it seems random, as my site as a decent traffic and so far it just happened 5 times):
[21-Feb-2012 23:43:19 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 261900 bytes) in /home/xxxxx/xxxxx/xxx.php on line 1811
The funny part is, the file has only 798 lines, and this never happened before to me.
It may have to do with recent changes I made to my scripts, yes, but this error simply doesn't make sense to me.
Please keep in mind that I know what "Allowed memory size exhausted" error means, and I know how to increase the memory limit.
However, my question here is, why is PHP referring to a line that doesn't exist?
I don't know how to fix this problem, because this makes no sense to me.
Thank you.
I've just found what was causing this memory leak.
It was a recent change that was entering in recursion cycle between two functions, although it was a rare event.
The line 1811 is real, yes, but the file that the error was referring is not correct. The line 1811 was from another file (included on that referred one) where one of the functions is.
I still appreciate the help from the people who commented above.

memory allocation issue - PHP

I am having really weird problem:
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 21748 bytes)
I understand that error however I am tracking all memory allocation for script and its not getting above: 2883584 in total.
The line before Fatal error is being triggered real memory usage is at a level of 2883584. As described in error above script is trying to allocate just extra 21748 more which is not adding up to 134217728 anyway.
Any ideas why its like that?
P.S.
for memory allocation usage I am using: memory_get_usage(true) function.
Consider passing true to memory_get_usage, which will return the true amount of system memory allocated (rather than just emalloc usage). The runtime is probably referring to system memory used when terminating your script, which may be much higher (e.g. through extensions which are not emallocing values).
OK, so I think I have found out the problem. As it turns out, if there is hard image to process GD2 allocation memory but you can't see it in memory_get_usage and get_peak so quite lame but...

PHP Fatal Error caused by Magento

So I'm checking my error logs and notice a bunch of these:
[20-Aug-2010 15:06:32] PHP Fatal error: Allowed memory size of 262144000 bytes exhausted (tried to allocate 16 bytes) in /home/website/public_html/lib/Zend/Db/Statement/Pdo.php on line 294
So I know that this has to do with the memory size set in php.ini, but it has been set to 250mb, which seems pretty high already for a VPS. There's quite a few of these errors, however front end performance is not affected.
Is it possible that I'm leaking memory somewhere, or is this a minor error?
Update: this is on a myriad of files:
app/code/core/Mage/Core/Model/Config.php
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
lib/Zend/Db/Select.php
Mostly on models it appears?
512mb is recommended and on our sites we use it.
There might be situation (ex: reindexing) where You can have problems.

Categories