In the following script:
$pageSize = 1000;
$productCollection = Mage::getModel('catalog/product')
->getCollection()
->addWebsiteFilter($website->getId())
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
for ($currentPage = 1; $currentPage <= $pages; $currentPage++) {
$productCollection->setCurPage($currentPage);
foreach ($productCollection as $productItem) {
$this->writeProductForStores($ioObject, $productItem, $stores, $defaultStore);
}
$productCollection->clear();
}
Let's say I've processed page #1, now I'm on the page #2, processing products 1001-2000, and I don't need products 1-1000 from the first page, but they're still in the memory (I'm monitoring the script execution from top)! And the memory consumption grows as the execution goes, then falling with exception of surpassing the memory limit.
How do I clear memory after finishing processing the previous page?
$this->writeProductForStores()for? – sv3n Oct 16 '18 at 20:21