Memory size of 1073741824 exhausted - Twig Environment Symfony2 - symfony

For some reason, I am suddenly getting the following Fatal error when clearing my cache in my Symfony2 project:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 130968 bytes) in /Applications/XAMPP/xamppfiles/htdocs/instorecrm/vendor/twig/twig/lib/Twig/Environment.php on line 286
When I refer to the line 286 in the Environment.php file, it is this function:
public function getCacheFilename($name)
{
#trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
$key = $this->cache->generateKey($name, $this->getTemplateClass($name));
return !$key ? false : $key;
}
I cannot think of anthing I've done that would cause this, the only change I have made is to the parameters.yml file to stipulate Gmail as my mail host. It does not seem to affect the working of the site (at least I have not found it to as yet) but it worries me that something might be broken.
I am using localhost, if that helps any.
Any help appreciated,
Thank you
Michael

Try cleaning the cache manually by deleting the app/cache folder.

Related

Local by Flywheel - Adminer - memory exhausted fatal error

this is the error when trying to import a 30MB SQL file:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 264241184 bytes) in /Applications/Local.app/Contents/Resources/extraResources/adminer/adminer.php on line 95
i'm going to try & work my way through this, & will post the answer here if i sort it out. if anyone has a quick/simple fix - please share.
thanks,
Jason
Click on the Open site shell
Once you in terminal, move your sql file to your app's public folder, and then run
wp db import your-file-name.sql

Wordpress wpadmin : Fatal error: Allowed memory size of 536870912 bytes exhausted

I am using woocommerce on my wordpress site. I wanted to filter out specific products by category. When I clicked the filter button, this error occurs:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 72 bytes) in /..../wp-includes/wp-db.php on line 1841
I checked and executed this : http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/
by adding define( 'WP_MEMORY_LIMIT', '256M' ); on wp-config, but still error occurs
Also, I don't have iThemes Security installed on my PC as seen on this link(though I installed before, I just only uninstalled)
WordPress Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 77 bytes) in wp-includes/wp-db.php on line 1832
FYI, I only have more than 10k of total products on my database.
Does anybody know?
To debug, you need to check how much memory php.ini allows the php to use.
create a phpinfo.php file under your website, put phpinfo() in:
<?php phpinfo(); ?>
Visit corresponding page and check PHP memory_limit number. If its too small, you can increase it by editing the php.ini. The path informaion of php.ini is also displayed on http://your.domain/phpinfo.php URL.
Then, find memory_limit = line:
memory_limit = 1024M ; /* Change the 1024M to your needs */
In addition, you may want to try to display less product in a single page. This may save some memory for you.

DOMDocument->load external entity fail for local file with PHP-FPM

The following PHP "failed to load external entity", even though it is trying to load a local XML file:
<?php
$path = "/usr/share/pear/www/horde/config";
#libxml_disable_entity_loader(false);
$dom = new DOMDocument();
$v = $dom->load($path . '/conf.xml');
echo "status = ".($v?'success':'error')."\n";
?>
The basic question is how can this be fixed?
Log file:
2014/03/10 20:07:10 [error] 26117#0: *24 FastCGI sent in stderr: "PHP message: PHP Warning: DOMDocument::load(): I/O warning : failed to load external entity "/usr/share/pear/www/horde/config/conf.xml" in /usr/share/nginx/html/test.php on line 5
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /usr/share/nginx/html/test.php:0
PHP message: PHP 2. DOMDocument->load() /usr/share/nginx/html/test.php:5" while reading response header from upstream, client: x.x.x.x, server: example.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com"
Uncommenting the libxml_disable_entity_loader line works, but this is not an acceptable solution for a few reasons, e.g. it is systemwide for php-fpm.
Running the PHP from shell returns "status = success". Doing a file_get_contents and then $dom->loadXML($string) also works (i.e. file exists and not a permissions issue). This might be an acceptable workaround, but shouldn't be necessary and doesn't explain why the error is occurring.
The XML file itself is the Horde config, but the problem does not seem to be the contents of the file, since it also occurs with this XML content:
<?xml version="1.0"?>
<configuration></configuration>
Environment is php and php-fpm 5.3.3, nginx 1.4.6, libxml2 2.7.6. My first guess is something to do with php-fpm, but I can't find any config setting that affects this. Any pearls of wisdom appreciated!
EDIT TO ADD
Restarting php-fpm causes it to work briefly. Disabling APC did not seem to help. Seems like something with php-fpm - but what?
FURTHER TESTING
Some additional info:
I tried hitting the server repeatedly, and get an error about 80% of the time. The pattern isn't random - a few seconds of successes followed by a series of errors;
I added a phpinfo() to the end of the above php and doing a diff on the success and failure runs - there is no difference;
If I put libxml_disable_entity_loader(true), I seem to always get an error, which suggests that bug #64938 is at work.
It seems that I need to find why the XML is considered to have external entities.
I think that, if the external entity loader is disabled, it should be obvious that external entities can't be loaded. The only solution is to enable loading of external entities with libxml_disable_entity_loader(false). Since this setting is not thread-safe, I can see two approaches:
Enable it globally and use some other feature to prevent loading of unwanted entities (typically from a network):
Register your own entity loader with libxml_set_external_entity_loader. I think that's the safest solution.
Use the parse option LIBXML_NONET. This should be enough if you simply want to disable network access of libxml2. But you have to make sure to always pass it to calls like DOMDocument::load.
Use locks to protect calls to libxml_disable_entity_loader. This is probably impractical and potentially unsafe.

Parse error when on production

I have developed a Symfony2 project (v2.2.2) and it was working all fine locally.
When I deploy it on my server I meet 2 issues:
the folder /bin does not transfer through Filezilla (impossible to start transfer)
i encounter a parse error when trying to access web/app.php/ in debug mode (see below)
First I do not understand why it would work in local but not on production.
I also guessed these errors where linked but I do not know what is /bin used for (contains only 2 files doctrine and doctrine.php) and if I remove it locally it keeps working ...
Parse error is the following :
"FatalErrorException: Parse: syntax error, unexpected '[' in /home/colocall/twinkler/src/Tk/ExpenseBundle/Services/Expenses.php line 21"
Expenses.php line 15->25:
public function getAllExpenses($member, $group)
{
$all_expenses_col = $group->getExpenses();
$all_expenses = array();
foreach($all_expenses_col as $expense){
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
}
return $all_expenses;
}
Maybe linked to : The parse error also happen when i try to update my database through ssh connection.
If someone would know the reason why I can't make it working it would save my day that i have already lost ...
Thank you in advance,
Jules
Your error is produced by using the short array syntax [] in your code.
It is not available in PHP 5.3.10 aka on your production server. The short syntax was introduced in PHP 5.4 which explains why your code is working in your dev-environment.
change ...
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
...to
$all_expenses[] = array($expense, $this->forYou($member, $expense));
... or update your server's php version and it will work :)

Symfony2 phpunit gives 503 error

I signed up to GitHub and forked Symfony2. I tried to run the Symfony2 tests according to the instructions. I type > phpunit but every time, after some tests, I suddenly get out of memory message:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40 bytes) in ...\Symfony\Component\HttpFoundation\HeaderBag.php on line 37
Then, the tests result is something like that:
503 Service Unavailable503 Service Unavailable503 Service Unavailable503 Service
Unavailable503 Service Unavailable503 Service Unavailable503 Service Unavailable
What may be causing it?
I ran into the same problem using the 2.0 branch. The full set of tests require approx. 163Mb of memory and like first answer said php defaults to 128M. You have two options.
Change the default max memory allocation to something greater than 163Mb.
memory_limit = 200M in php.ini
or
copy phpunit.xml.dist to phpunit.xml
alter the attribute bootstrap to read bootstrap="tests/local-bootstrap.php"
add an entry into your .gitignore for tests/local-bootstrap.php
create local-bootstrap.php with something like:
local-bootstrap.php
<?php
ini_set('memory_limit', '200M'); // might need to adjust the value
require 'bootstrap.php' // no need to duplicate the bootstrap
This way allows you to add local changes without having to worry about git tacking any modifications to files that are local to your machine.
That is because the script exceeded the maximum amount of memory defined in php.ini
By default is 128M (134217728 bytes)
Here is explained http://php.net/memory-limit

Resources