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
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
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With