3

While trying to generate a database with a command:

php bin/console doctrine:schema:update --force

I'm getting these errors:

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in ...\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 281

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in ...\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 281

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

I have already tried all possible settings of memory_limit in php.ini, nothing helped.

With:

php bin/console doctrine:schema:update --dump-sql

the errors are:

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in ...\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 281

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in ...\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 281

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

10
  • Can we see the code you are working with? It looks like your PHP app is already using 1G of RAM, which sounds very excessive. Commented Jun 11, 2016 at 15:02
  • Which part of code do you need to see? It is a complete symfony application. As far I know, the schema:update command access only the mapping files in src\AppBundle\Entity. There are 18 of them in my application. 1024M is my current setting in php.ini. When I set it to 128M the error is PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in ...\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php on line 281 Commented Jun 11, 2016 at 15:18
  • And tell us what's in your /etc/php or /etc/php5 directory. Probably you have different settings for web server and CLI. Commented Jun 11, 2016 at 15:19
  • What happens if you use --dump-sql? Running out of memory on a schema update is strange. Maybe a mapping error. And run php --ini just to double check which ini file is being used from the console. Commented Jun 11, 2016 at 15:29
  • I'm running the application locally. I've set php as environmental variable and run the application in command line. There is no such a directory like etc. Do you mean you need to see the php.ini file? Commented Jun 11, 2016 at 15:30

1 Answer 1

0

In my case, this error was caused by a very specific mistake:

My User mapping had a custom repository class set up. Said repository had a constructor like the following, which caused an infinite loop:

public function __construct(private EntityManagerInterface $manager)
{
    $this->repository = $manager->getRepository(User::class);
}

Since I didn't really need the custom repository, it was just a matter of removing it from the mapping.

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

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.