4

I try to run this command to build model in my symfony project(1.4) :

php symfony propel:build-model( or all ) 

I have this error :

PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 20 bytes) in /home/sfprojects/jobeet/lib/vendor/symfony/lib/util/sfClassManipulator.class.php on line 176

I searched before asking people here so I changed memory_limit = 64M in my php.ini to 128M , 510M , 1024M ... but I have the same error that really get me crazy!

I'm using Ubuntu with apache2,php5...

4
  • 1
    are you sure your are changed the memory_limit value in the correct php.ini? Try echo ini_get('memory_limit') somewhere in your script to see the value used Commented Jun 27, 2013 at 22:27
  • plz don't answer if you don't have a good solution please... Commented Jun 27, 2013 at 22:35
  • I'm not stupid to not put value in the correcte php.ini Commented Jun 27, 2013 at 22:38
  • 3
    Insulting people that try to help you won't get you far. We don't know what you have tried. You would be surprised how many problems on SO are solved with a "clear cache" or "make sure it's the right .ini". That's why @Bruno-P added this as a comment not as a solution. As for the problem - can you also make sure you're using Sf 1.4.20? And another one - do you get exactly the same error when changing the memory setting? (are all the digits the same?) Commented Jun 28, 2013 at 8:13

7 Answers 7

6

Make sure you edited your php.ini file for php-cli and not for Apache. In /etc/php5/cli/php.ini for your Ubuntu.

Sign up to request clarification or add additional context in comments.

1 Comment

In Ubuntu it defaults to: memory_limit = -1 , that means no memory limit for the cli environment.
2

Edit: Sorry, this was meant as a response to How can I increase the allowed memory size in Symfony? (I had both open at the same time.)

You probably have something like this in your composer.json:

"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",

Replace it by

"scripts": {
    "auto-scripts": {
        "php -dmemory_limit=512M bin/console cache:clear": "script",

Comments

1

You should avoid putting dump in loops in your

Controllers

or in your twig templates with

{% for row in rows %}
   {{ dump(row) }}
{% endfor %}

Comments

1

I add this comment here because this is the second page that pops out for the search term "Php symfony: Fatal error Allowed memory size of xx bytes exhausted".

I recently encountered this issue with Symfony 6.3.7. It takes me a couple of days to solve because I didn't find the right resource on the internet that could help.

In general, increasing the memory_limit is not the best solution (btw, I've set mine to -1 and increased the max_x_time, but nothing). You'll need to investigate to find the root cause of the issue.

For me, the $kernel->handle($request); in public/index.php could not terminate its execution or throw an error, therefore there were no symfony dump/log neither in the CLI nor in the browser, I just got HTTP ERROR 500 from the browser. I've followed the $kernel->handle function until PhpDumper.php in vendor with a bunch of dumps and then used git diff. It turns out there were a circular reference exception that has not been detected/controlled by the ServiceCircularReferenceException and I have no idea why. I tried to reproduce the same error with Symfony 5.4, Symfony 6.3.8, and it has been properly handled.

Finally, thanks to git diff, I removed the dependency injections that led to the endless recursion and everything is now running smoothly with just 128M of memory.

Code example for my case(all projects on debug mode):

Service2 calling Service1.

<?php

namespace App\MyModule\Service;

use App\Service\XService\Service1;

class Service2
{
    public function __construct(private Service1 $service1)
    {
    }
}

Service1 calling Service2

<?php

namespace App\Service\XService;

use App\MyModule\Service\Service2;

class Service1
{
    public function __construct(private Service2 $service2)
    {
    }
}

Comments

0

Install Symfony from the oficial page.

symfony composer update

symfony composer = Runs Composer without memory limit

Comments

-1

However this wont probably solve it, in your .htaccess of your project root folder (/web), add the following line:

php_value memory_limit 1024M

Pay attention to what Bruno-P already told you, make sure that you are already changing the right php.ini file for your symfony project. If you have more than one php installation its possible that you are changing an old file.

Make sure also you are typing it right in your php.ini:
Symfony 1.4: PHP Fatal error: Allowed memory size of 33554432 bytes exhausted

Clear symfony cache (symfony cc), close the web server and execute the command again:

symfony propel:build-model

You may also check your php configuration for your memory values limit set. Make a new file in your project with the content:

<?php
  phpinfo();
?>

Comments

-3

Try putting:

<?php  ini_set('memory_limit', '3G'); ?>

at the top of your ./symfony file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.