MongoDB で 15,000 のドキュメントを参照しようとしています。Doctrine ODM を使用すると、PHP の使用メモリが爆発します。シーケンシャル スクリプトを作成しますが、メモリはまだ大きくなります。
$nbrNoticesTotal = $noticesNbr['count'];
$page = 0;
$limit = 500;
$pt = 0;
$ptTotal = 0;
$notices = $dm->getRepository('Notice')->findLimit($page, $limit)->toArray();
if ($nbrNoticesTotal > 0) {
while ($ptTotal < $nbrNoticesTotal) {
if ($pt >= $limit) {
unset($notices);
$this->getContainer()->get('doctrine.odm.mongodb.document_manager');
$page += $limit;
$notices = $dm->getRepository('Notice')->findLimit($page, $limit)->toArray();
$pt = 0;
}
foreach ($notices as $key => $notice) {
$pt++;
$ptTotal++;
//unset($notice);
unset($notices[$key]);
}
}
}
memory_get_usage() の例:
2012-06-28 14:53:08.541-defaultLogger-DEBUG Start : 20,339,624
2012-06-28 14:53:10.154-defaultLogger-DEBUG get package : 1 - 64,207,344
2012-06-28 14:53:10.891-defaultLogger-DEBUG pointer time : 64,250,536
2012-06-28 14:53:11.642-defaultLogger-DEBUG pointer time : 64,246,952
2012-06-28 14:53:12.375-defaultLogger-DEBUG pointer time : 64,243,368
2012-06-28 14:53:13.140-defaultLogger-DEBUG pointer time : 64,239,784
2012-06-28 14:53:13.911-defaultLogger-DEBUG pointer time : 64,236,264
2012-06-28 14:53:15.359-defaultLogger-DEBUG get package : 2 - 104,447,576
2012-06-28 14:53:17.259-defaultLogger-DEBUG pointer time : 104,482,168
2012-06-28 14:53:19.013-defaultLogger-DEBUG pointer time : 104,478,584
2012-06-28 14:53:20.771-defaultLogger-DEBUG pointer time : 104,475,000
2012-06-28 14:53:22.650-defaultLogger-DEBUG pointer time : 104,471,416
2012-06-28 14:53:24.575-defaultLogger-DEBUG pointer time : 104,467,840
2012-06-28 14:53:26.081-defaultLogger-DEBUG get package : 3 - 139,016,152
2012-06-28 14:53:29.192-defaultLogger-DEBUG pointer time : 139,046,936
2012-06-28 14:53:32.560-defaultLogger-DEBUG pointer time : 139,043,360
2012-06-28 14:53:35.456-defaultLogger-DEBUG pointer time : 139,039,912
2012-06-28 14:53:38.229-defaultLogger-DEBUG pointer time : 139,036,336
メモリをクリアするにはどうすればよいですか? (アンセットは機能しません)