我寫了一個symfony任務來填充示例數據的數據庫。以下是一段代碼示例:Symfony任務 - 內存泄漏
gc_enable();
Propel::disableInstancePooling();
public function test()
{
for($i = 0; $i < 10000; $i++) {
$this->doIt($i);
}
}
public function doIt($i)
{
$user = new User();
$user->setUsername('user' . $i . "@example.com");
$user->setPassword('test');
$user->setFirstName('firstname' . $i);
$user->setLastName('surname' . rand(0, 1000));
$user->save();
$user->clearAllReferences(true);
$user = null;
gc_collect_cycles();
}
如何限制內存的使用?
可能重複http://stackoverflow.com/questions/2097744/php-symfony-doctrine-memory-leak – j0k