Chris Sz.
Chris Sz.

Reputation: 31

Symfony 3 Doctrine PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)

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

Upvotes: 3

Views: 3199

Answers (1)

pulmunyi
pulmunyi

Reputation: 1

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.

Upvotes: 0

Related Questions