Out of memory error in symfony

前端 未结 6 1860
心在旅途
心在旅途 2020-12-10 12:18

I\'m currently working on Symfony project (const VERSION =\'2.5.10\') and I am using xampp. PHP version is 5.5.19.

My problem is everytime I run my dev environment I

相关标签:
6条回答
  • 2020-12-10 12:48

    If the memory limit is only being reached under the Symfony dev environment I would suggest adding the following to web/app_dev.php

    ini_set('memory_limit', '-1');
    

    This way you can continue to test the production with a sensible amount of memory. Modifying the whole environment via php.ini could hide an error down the line.

    0 讨论(0)
  • 2020-12-10 12:50

    Even late to the party, recently I had problems about Out of Memory just accessing app.php file with Symfony 3.4. Turns out that when you have SELinux set to enforcing, even if you set the permissions of var directory inside your project to 777, it won't be able to write on it. If you follow the steps in the official documentation about how deploy in production, it will return a response code 500 and write in web server's error log only that PHP has exhausted the memory limit.

    I'm no expert in SELinux, but the only way I could solve this problem was disabling SELinux, but edition /etc/selinux/config file setting SELINUX=disabled and restarting the OS.

    Again, there's reason to SELinux exists and proper configuration isn't found easily using Symfony's var sub-folders and can get hard to solve this problem without thinking of disabling SELinux.

    0 讨论(0)
  • 2020-12-10 12:57

    The most eager component in Symfony is a profiler. If you don't need profiler in some particular actions you can disable it via code:

    if ($this->container->has('profiler'))
    {
        $this->container->get('profiler')->disable();
    }
    

    You can also set global parameter in config:

    framework:
        profiler:
            collect: false
    
    0 讨论(0)
  • 2020-12-10 12:57

    You either disable symfony profiler (I don't think this is what you want as far as I know) or set limit to unlimited with -1 in your php.ini and restart apache.

    memory_limit = -1
    
    0 讨论(0)
  • 2020-12-10 12:58

    This may help :

    php -d memory_limit=-1 /usr/local/bin/composer require ggergo/sqlindexhintbundle 
    
    0 讨论(0)
  • 2020-12-10 13:10

    I solved the Out of memory error on the Twig debug by installing the XDebug.

    Because the Twig uses the PHP var_dump function internally, install the XDebug is a good idea, because it limits the var_dump() output of arrays and objects to 3 levels deep, as we can see on the documentation.

    Credits to @peezi.

    0 讨论(0)
提交回复
热议问题