The original installation was on Ubuntu 14.04 with PHP 5.5.9 and CakePHP 5.4.1. After migrating to Ubuntu 16.04 with PHP 7.0.30 I updated CakePHP to 2.10.4 mainly by exchanging the lib folder. Everything works fine in the web interface, even the memory consuming tasks of the application.
But the CLI is broken. Every call to 'app/Console/cake' throws a 'PHP Fatal error'.
root#watt18:/var/www_external/app# Console/cake bake
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /var/www_external/lib/Cake/Console/ConsoleOptionParser.php on line 510
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in /var/www_external/lib/Cake/I18n/I18n.php on line 1
The 'in' part changes from call to call. Searching the web I could not find any comparable topic. I checked the persmissions on all the folders inside 'app' but could not find any differences to the original installation. I tried to debug but couldn't get really far yet. Up to the line return ShellDispatcher::run($argv); in Console/cake.php everything is fine.
I get the same result when making a call inside the original cakephp folder from a fresh download.
I have no idea where all the memory gets lost.I would be happy about any hint to what might cause the problem or how to continue with debuging.
set memory_limit = -1 in your php.ini
but this is not a good solution , you may have a memory leake somewhere
please double check your statements , specialy if there is a loop with many memory usage
Related
I've been working for hours on this issue and I'm about to get mad ! I develop a Symfony 3 application for more than a year, without any big problem. I was implementing some DoctrineEventListeners to my User Entity, everything was fine. But I now have an Error 500 for each page I want to access to (even the ones where there is NO call to these EventListeners). And my php log says this :
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Applications/MAMP/htdocs/symfonyjf/var/cache/dev/ContainerXu4ttxs/getDoctrine_Orm_DefaultEntityManagerService.php on line 41
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Applications/MAMP/htdocs/symfonyjf/vendor/symfony/debug/Exception/OutOfMemoryException.php on line 1
I reversed all my last changes, so there is no "new" EventListener in my project. But still, the project still shows a blank page.
Do you have any clue to help me ?
Thanks a lot !
At first you have to clear your cache so you are sure that you are running the correct version of code. Secondly I suggest to use the Symfony Stopwatch Component in order to monitor the memory usage of different code blocks in your project in order to understand where you have the largest memory consumption. Finally, if you can (i.e. you are not using a shared hosting environment) increase PHP allowed memory in your php.ini file.
I finally checked service by service and I found the one that was causing what I guess was an infinite loop. It was an Injection of EntityManager inside a service triggered by a Doctrine EventListener, which is (I guess) not allowed.
Thanks everybody !
When calling Symfony's Uploadfile->getMimeType() on a csv file with 1100 rows and 60 columns and ~400kb size, $finfo->file tries to use around 5gb memory which gives me the following error:
Fatal error: Allowed memory size of 1077936128 bytes exhausted (tried to allocate 4294937911 bytes) in /vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php on line 69
This is the part of code that gives that error:
if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) {
return;
}
return $finfo->file($path);
Btw this happens on our production server that has PHP version 5.4, but doesn't happen on my dev server with php 7.
There is a bug in php 5.4 (already fixed in 2015, so you really should upgrade the php version in your server) that cause finfo::file function to allocate huge amounts of memory when trying to extract the info of a csv file.
Here is the link to the bug:
https://bugs.php.net/bug.php?id=69224
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.
In my php error log for about a months ago i see an error
PHP Fatal error: Out of memory (allocated 524288) (tried to allocate 311296 bytes) public_html/index.php on line 347
It's strange because the error says that it allocated only 524288 which would be 512 KB
the error is the same as always and occurs only on this line of script and i get about 10-20 times this error per day
in index.php i have included 4-5 script and on that line (ln 347) there is which only returns some css codes and There is no infinite loop
I've read a lot of topics and changed mempry_limit to 256M and added RLimitMEM 173741824 247483648 and MaxRequestsPerChild 9000 In apache
In my tests i use a code like this
if($_SERVER['REMOTE_ADDR'] == $my_IP)
{
var_dump(memory_get_usage());
var_dump(memory_get_peak_usage());
}
in on the beginning and the end of script which results:
int(729812) int(741124) - int(915952) int(953968)
I have a vps with php 5.3.22 installed and with 1.5 GB ram where most of times 200-500 mb is free and i have something about 20,000 hits per day maybe more and server load sometimes goes to 8 for a little period of times
the website is very fast and there is nothing wrong with speed
in the root there are 3-4 php files which is accessible by public too but in error log i dont see them although they dont have that hits as index.php
in my localhost i install x-debug and win cache grind and when i profile the index.php script i see nothing wrong in there too
On this vps i've also install wordpress which gives errors too but at least the amount of memory he could allocated is more, one of the error is like this:
PHP Fatal error: Out of memory (allocated 9961472) (tried to allocate 7 bytes) in /public_html/blog/wp-includes/canonical.php on line 157
for the wordpress i'v set memory_limit 256M in htaccess
I have also install livezilla which gives errors too
PHP Fatal error: Out of memory (allocated 524288) (tried to allocate 77824 bytes) in public_html/support/_lib/functions.global.inc.php on line 520
for the livezilla i'v also set memory_limit 256M in htaccess
I should mention that in my vps i've hosted 5-6 other websites
And one time i faced with this error in phpMyAdmin that says:
PHP Fatal error: Out of memory (allocated 524288) ...
again only allocated 524288
Iv restarted apache over and over but nothing changes
Could the line number in error log be wrong due to including other scripts before that line?
Could it be the Cpu issue?
I'm struggling with this error about 2 months and i don't know what to do else
any idea?
It's very likely that your webserver is miss configured regarding memory consumption, allowed concurrent requests and available memory.
Evaluate your logs to see how many and what concurrent requests you have on such peaks. You might stress your server with ab to reproduce those situations. 1.5 GB ram for 20k hits a day just feels wrong. Check your webserver configuration how many concurrent requests are allowed and how big a fork might grow. I'm quiet certain they will easily eat up those 1.5 GB.
setting configuration for prefork in apache worked!
I'm working on a wordpress website and I'm attempting to set up a local test-environment for development purposes. I'm running the MAMP (Mac Apache MySQL PHP) stack.
I'm running into the following error:
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 4864 bytes) in /Users/casey/Documents/workspaces/yofreesamples.com/wp-includes/functions.php on line 1174
I've attempted to increase the memory limit by modifying line 28 in wp-config.php:
define('WP_MEMORY_LIMIT', '2024MB');
and by including the following value in index.php
ini_set('memory_limit','64M');
without any luck for any memory values I've tried. I'm relatively new to wordpress, anyone have any idea what's going on?
Perhaps the MAMP configuration doesn't allow you to override the memory limit programmatically. Set it in php.ini as described here.