s4lfish
s4lfish

Reputation: 633

Magento memory performance

I have a huge problem in Magento 1.7.0.2 when importing ~400k of products. Due to an custom interface i created a custom product import where the products get created, upsellungs/cross-sellings get saved.

Pseudo:

do {
  if( $_product = Mage::getModel(catalog/product)->loadByAttribute('sku', $sku)){
     return $_product;
  }else{
     $product = $this->createProduct();
     $product->save();
  }
}while(!$end_of_import);

Each processed product (load/save...) needs ~180kb of memory. The problem: the memory never gets released! So after ~50k-60k of imported products the allowed memory size of 10gb is exhausted.

I tried different solutions as posted here or here but no effect.

Upvotes: 0

Views: 808

Answers (3)

Tobias
Tobias

Reputation: 1682

Call $product->clearInstance() after the save, so not only the product itself is removed, but also everything else attached to it.

Upvotes: 2

Péter Gulyás
Péter Gulyás

Reputation: 1111

How about the indexes? On the backend interface the Indexing is set to "update on save" by default. If you iterate over a lot of products and save them as you described, a reindexing process will start after each save. Try to change the mode to "Manual" (System/Index management), and execute the import afterwards.

Upvotes: 3

Pablo
Pablo

Reputation: 547

Have you tried using unset ? for $_product and $product?

Upvotes: 0

Related Questions