Reputation: 452
I'm using Symfony2 for my project and in my model, some of the entities are so many (more than 150 000 instances) I'm using the ORM Doctrine2 to persist them in the Database Management System MySQL the problem is that after fixturing one table with only 26 000 rows I can't load one of the page of my project again. Symfony2 throw the following error each time allthough I edited the php.ini
file by increasing the memory size to from 128 to 512 M and clear the cache.
error generated by Symfony (2.7) :OutOfMemoryException in Profile.php line 153:
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 5131594 bytes)
Notice that I'm using sonata-adminBundle also to manage my entities.
Upvotes: 2
Views: 2071
Reputation: 4491
There are at least four ways to decrease memory usage:
1) enforce garbage collector to do its job gc_collect_cycles();
2) clear entity manager to detach objects if you don't need them anymore
$em->flush();
$em->clear();
3) disable SQL logger, for instance
$em->getConnection()->getConfiguration()->setSQLLogger(null);
Here you can read a bit more.
4) use doctrine pagination where you have to handle a lot of entities
Upvotes: 4