我正在开发一个循环/迭代10,000多次的PHP脚本:
foreach ($array_with_items as $item) {
// Instantiate the object
$obj_car = new CarAds($puk, 'ENG', '5');
$obj_car->detail1 = "Info about detail1";
$obj_car->detail2 = "Info about detail2";
$obj_car->detail3 = "Info about detail3";
$obj_car->detail4 = "Info about detail4";
// Saves to the database
$obk_car->save;
}
当我运行这段代码时,我的机器会耗尽内存。在这个foreach循环中,我该怎么做才能清理内存?
$obj_car
,但后面却出现了$obk_car
,这是有意为之吗? - Alex