-1

i got this error when using php bin/console server:run , and the server won't start. php bin/console server:run

Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in C:\Users\Messkan\Desktop\businessplace\vendor\jms\serializer-bundle\JMSSerializerBundle.php on line 43

Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in C:\Users\Messkan\Desktop\businessplace\vendor\symfony\symfony\src\Symfony\Component\Debug\Exception\OutOfMemoryExce ption.php on line 1

  • Possible duplicate of [Diagnosing Memory Leaks - Allowed memory size of # bytes exhausted](https://stackoverflow.com/questions/849549/diagnosing-memory-leaks-allowed-memory-size-of-bytes-exhausted) – Mike Aug 04 '18 at 03:19
  • 2 MB is extremely low. You're going to want to increase your memory limit. – Mike Aug 04 '18 at 03:19
  • See also, this setting: http://php.net/manual/en/ini.core.php#ini.memory-limit – Mike Aug 04 '18 at 03:20
  • how to increase it using hctaccess ? i use php 7? – Skander Ben Khelil Aug 04 '18 at 10:27

3 Answers3

2

You probably have either:

  1. An entity related to thousands of other entities, and by the time you get to a very high amount of records being serialized, memory maxs out, or...
  2. A circular reference in one of your entities

Increasing the memory limit may fix it if is not a circular reference, but that's not a proper fix. You have to be efficient. Control your hydration and references. Also, IMO, JMS Srializer is not the best tool for a presentation layer. Try league/fractal.

1

use this command to increase memory allocated: php -d memory_limit=-1 bin/console server:run

or increase this option in php.ini in your php folder.

0

You need to increase memory_limit value in php.ini file for the php version you are using (e.g. php7.0).

So navigate to your php.ini file there, find memory_limit line in this file & try to set value to 1G or 2G (depending on the app size, - how much you really need). Save changes & restart your server (apache/nginx), and try once again.

Pavel Vasiluk
  • 187
  • 1
  • 11