Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes)
Asked Answered
H

1

5

Few days ago I started a new Symfony2 application and I get some troubles with cache:

$ rm -rf ./app/cache/*
$ rm -rf ./app/logs/*
$ ./app/console cache:clear

Clearing the cache for the dev environment with debug true

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in /Users/simonegentili/Development/Www/shop_website/vendor/twig/twig/lib/Twig/Node/Text.php on line 23

And ...

$ ./app/console cache:clear --env=prod

works fine.

Heine answered 9/3, 2013 at 8:4 Comment(3)
Does just a simple rm -rf app/cache/* work for you? Also you might want to open up a bug report on the Symfony GitHub page.Papillose
No sorry, but thaks. I've updated question.Heine
As a quickfix, can you try and up the memory_limit in php.ini to say.. 64MB?Papillose
C
14

I had such problem in the past. Looks like for big projects this CLI script try to make too much work. As I discover it possible set amount of memory available in this case:

sudo php -d memory_limit=256M app/console cache:clear
Caliph answered 10/3, 2013 at 12:22 Comment(7)
i will not recommend use sudo since after that you will always need to use sudo to warmup the cache. Try increasing memory limit from php.ini insteadValparaiso
Increasing memory limit in php.ini will increase it to all php scripts. Why we should do it if have only this one heavy operation?Follansbee
Because we will need clear cache more than once, especially in development environment.Valparaiso
Sure, but it's not argument to increase memory limit for all scripts of site :)Follansbee
I don't think its will backfire if we set php.ini, since i assume php CLI (which can only be accessed by developer) will use diff php.ini with accessed website. But with not increasing php.ini we will need always (which will always give us extra typing) put that memory limit when we want to clear cache.Valparaiso
Talent to tell same things by different words.. Are production cache will not need to be cleared sometimes? Anyway, I prefer to economy memory, you prefer to economy typing. Let's readers decide what is more important for themFollansbee
Just FYI, the default memory_limit for php (aka php-cli) should be -1, or infinite. Check this by running php -i | grep memory_limitParrish

© 2022 - 2024 — McMap. All rights reserved.