Recursive error in PHP - php

I am trying to migrate a database from an old XP machine to a new Synology DS213. I successfuly imported the database and mirrored permissions, but am having trouble actually getting the website to work. I run out of memory no matter how high I raise the max memory limit.
I was able to install the xdebug extention to help me debug. I have tryied I quickly run out of memory with the following error: (this is just the first couple of lines)
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried
to allocate 70987243 bytes) in /volume1/web/includes/phpFunctions.php
on line 203 Call Stack: 0.0011 324280 1. {main}()
/volume1/web/index.php:0 0.0024 324728 2.
require('/volume1/web/includes/phpFunctions.php')
/volume1/web/index.php:14 0.0646 337424 3. phpMySQL->dbQuery()
/volume1/web/includes/phpFunctions.php:35 0.0653 337568 4.
phpMySQL->stopProcess() /volume1/web/includes/db/mySQL.php:69 0.0655
337968 5. myErrorHandler() /volume1/web/includes/db/mySQL.php:254
0.0662 343400 6. raiseError() /volume1/web/includes/phpFunctions.php:160 0.0670 344608 7.
phpMySQL->dbQuery() /volume1/web/includes/phpFunctions.php:209 0.0678
345792 8
I am at a loss. I don't expect anyone to solve it for me, but hopefully point me in the right direction to learn more about the errors.

Try add this line to your script (possibly in index.php) -
#ini_set('memory_limit', '1G');
If this doesn't work then try import database again in this way - first import 2/3 table then again next 2/3 table and so on and also make sure that there is no infinite loop(s).

Related

cakephp cli throws PHP fatal error

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

Blank page and memory size exhausted

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 !

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.

PHPUnit code coverage memory limit

I have a Symfony2 project with some functional tests.
When I run the test suite without code coverage enabled, there is no problem.
But when I am trying to generate the code coverage I am getting a PHP Fatal error :
Generating code coverage report, this may take a moment.
PHP Fatal error: Allowed memory size of 209715200 bytes exhausted
(tried to allocate 79 bytes) in /usr/share/php/PHP/Token/Stream.php on line 205
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP 5. PHP_CodeCoverage_Report_HTML->process() /usr/share/php/PHPUnit/TextUI/TestRunner.php:373
PHP 6. PHP_CodeCoverage->getReport() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:133
PHP 7. PHP_CodeCoverage_Report_Factory->create() /usr/share/php/PHP/CodeCoverage.php:141
PHP 8. PHP_CodeCoverage_Report_Factory->addItems() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:76
PHP 9. PHP_CodeCoverage_Report_Factory->addItems() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:98
PHP 10. PHP_CodeCoverage_Report_Node_Directory->addFile() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:94
PHP 11. PHP_CodeCoverage_Report_Node_File->__construct() /usr/share/php/PHP /CodeCoverage/Report/Node/Directory.php:211
PHP 12. PHP_CodeCoverage_Util::getLinesToBeIgnored() /usr/share/php/PHP/CodeCoverage/Report/Node/File.php:166
PHP 13. PHP_Token_Stream_CachingFactory::get() /usr/share/php/PHP/CodeCoverage/Util.php:254
PHP 14. PHP_Token_Stream->__construct() /usr/share/php/PHP/Token/Stream/CachingFactory.php:68
PHP 15. PHP_Token_Stream->scan() /usr/share/php/PHP/Token/Stream.php:147
I already modified memory_limit for both cli and server php.ini.
I also already modified the memory_limit of suhosin.
When I print a phpinfo() in the cli I got these values :
memory_limit => 2048M => 2048M
suhosin.memory_limit => 2G => 2G
Does anyone has an idea of what may be causing this problem ? Has anyone faced such a situation ?
Looks like it stops at 200 Megabytes so either you need to look through your config more to allow more memory to be used or you have an include loop somewhere in the code. This has happened to me with twig includes a couple of times
Increase your PHP Memory Limit (I used 1744M to leave some safety space for PHP). I had the same problem before doing the extra memory. The next thing I changed was to exclude external libraries from the code-coverage (they are tested in their package by the author, so I do not need to know their code-coverage in my project). This allowed our project to then parse properly and get proper code coverage analysis.

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.

Categories