Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out of memory error in symfony

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 get an error :

OutOfMemoryException: Error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 3358976 bytes) in C:\xampp\htdocs\Editracker\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Profiler\FileProfilerStorage.php line 153

and everytime I refresh the page it gives different memory size. I also think that this is also the reason why my dev environment takes a lont time before it refreshes the page.

Your help is appreciated.

php.ini

memory_limit= '256M'

I tried to increase my memory limit,still it gives an error about memory limit

like image 818
aiai Avatar asked May 14 '15 05:05

aiai


4 Answers

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
like image 53
Michael Sivolobov Avatar answered Sep 21 '22 13:09

Michael Sivolobov


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
like image 31
BentCoder Avatar answered Sep 21 '22 13:09

BentCoder


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.

like image 22
valdeci Avatar answered Sep 19 '22 13:09

valdeci


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.

like image 35
lookbadgers Avatar answered Sep 18 '22 13:09

lookbadgers