Discussion:
Doctrine Error : Allowed memory size of 134217728 bytes exhausted
Iftah Abdelghafour
2013-10-18 11:54:22 UTC
Permalink
Hi everyone,

I'm getting this error:

emergency.EMERGENCY: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 8388608 bytes)
{"type":1,"file":"/appli/orpea/www/DAP/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php","line":2632}

It's because of sql select that returns over 1000 rows.

Where can I increase the memory size.

Thank you in advance.


Best regards,
iftah
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Marco Pivetta
2013-10-18 11:57:28 UTC
Permalink
That's a PHP setting.

Also, you shouldn't hydrate that many records in a single query (maybe even
with fetch-joined results?). Consider using a paginator instead

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/
Post by Iftah Abdelghafour
Hi everyone,
emergency.EMERGENCY: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 8388608 bytes)
{"type":1,"file":"/appli/orpea/www/DAP/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php","line":2632}
It's because of sql select that returns over 1000 rows.
Where can I increase the memory size.
Thank you in advance.
Best regards,
iftah
--
--
If you want to report a vulnerability issue on Symfony, please read the
procedure on http://symfony.com/security
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Odaepo
2013-10-18 13:28:45 UTC
Permalink
Post by Iftah Abdelghafour
Where can I increase the memory size.
-in php.ini file modify th parameter "memory_limit".
-writeing this line in the code ini_set('memory_limit', '16M');

Consider other way to write the code.
Look at these examples:

$batchSize = 20;
for ($i = 1; $i <= 10000; ++$i) {
$user = new CmsUser;
$user->setStatus('user');
$user->setUsername('user' . $i);
$user->setName('Mr.Smith-' . $i);
$em->persist($user);
if (($i % $batchSize) === 0) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
}



<?php
$q = $this->_em->createQuery('select u from MyProject\Model\User u');
$iterableResult = $q->iterate();
foreach ($iterableResult AS $row) {
// do stuff with the data in the row, $row[0] is always the object

// detach from Doctrine, so that it can be Garbage-Collected immediately
$this->_em->detach($row[0]);
}
Post by Iftah Abdelghafour
Hi everyone,
emergency.EMERGENCY: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 8388608 bytes)
{"type":1,"file":"/appli/orpea/www/DAP/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php","line":2632}
It's because of sql select that returns over 1000 rows.
Where can I increase the memory size.
Thank you in advance.
Best regards,
iftah
--
--
If you want to report a vulnerability issue on Symfony, please read
the procedure on http://symfony.com/security
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/groups/opt_out.
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Iftah Abdelghafour
2013-10-18 13:32:14 UTC
Permalink
Thank you all for your replies, I'll try your suggestions.

Thank you.
Post by Odaepo
Post by Iftah Abdelghafour
Where can I increase the memory size.
-in php.ini file modify th parameter "memory_limit".
-writeing this line in the code ini_set('memory_limit', '16M');
Consider other way to write the code.
$batchSize = 20;
for ($i = 1; $i <= 10000; ++$i) {
$user = new CmsUser;
$user->setStatus('user');
$user->setUsername('user' . $i);
$user->setName('Mr.Smith-' . $i);
$em->persist($user);
if (($i % $batchSize) === 0) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
}
<?php
$q = $this->_em->createQuery('select u from MyProject\Model\User u');
$iterableResult = $q->iterate();
foreach ($iterableResult AS $row) {
// do stuff with the data in the row, $row[0] is always the object
// detach from Doctrine, so that it can be Garbage-Collected immediately
$this->_em->detach($row[0]);
}
Hi everyone,
emergency.EMERGENCY: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 8388608 bytes)
{"type":1,"file":"/appli/orpea/www/DAP/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php","line":2632}
It's because of sql select that returns over 1000 rows.
Where can I increase the memory size.
Thank you in advance.
Best regards,
iftah
--
--
If you want to report a vulnerability issue on Symfony, please read the
procedure on http://symfony.com/security
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
--
If you want to report a vulnerability issue on Symfony, please read the
procedure on http://symfony.com/security
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to a topic in the
Google Groups "Symfony2" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/symfony2/euqxk-79uEA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/groups/opt_out.
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...