cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Updating product takes to much memory

Magento 2 Updating product takes to much memory

I'm having difficulties of keeping the memory usage of my script under the memory limit.

At this point I'm only getting the requested product and stock item which I then save without modifying it.

$product = $objectManager->get('Magento\Catalog\Model\Product')->load($_product->getId());
$stockitem = $stockRegistry->getStockItem(    $product->getId(),    $product->getStore()->getWebsiteId()
);
$product->save();

In the following output I printed the memory usage after every save.

 

  • 3DOO230050 - update product update 3DOO230050 80.66MB
  • 3DOO230051 - update product update 3DOO230051 96.35MB
  • 3DOO230052 - update product update 3DOO230052 112.29MB
  • 9POC170100 - update product update 9POC170100 127.99MB
  • 9POC170101 - update product update 9POC170101 144.18MB
  • AAPJ800202 - update product update AAPJ800202 159.88MB
  • ACCE272010 - update product update ACCE272010 175.57MB
  • ACCE272012 - update product update ACCE272012 191.26MB
  • ACCE272025 - update product update ACCE272025 206.96MB
  • ACCE272027 - update product update ACCE272027 223.66MB
  • ACCE272028 - update product update ACCE272028 239.36MB
  • ACCE272031 - update product update ACCE272031 255.06MB
  • ACCE272032 - update product update ACCE272032 270.76MB
  • ACCE272033 - update product update ACCE272033 286.46MB
  • ACCE272034 - update product update ACCE272034 302.17MB
  • ACCE272035 - update product update ACCE272035 317.87MB
  • ACCE272036 - update product update ACCE272036 333.57MB
  • ACCE272037 - update product update ACCE272037 349.28MB
  • ACCE272038 - update product update ACCE272038 364.98MB
  • ACCE272039 - update product update ACCE272039 380.69MB
  • ACCE272040 - update product update ACCE272040 398.41MB
  • ACCE272045 - update product update ACCE272045 414.13MB
  • ACCE272046 - update product update ACCE272046 429.85MB
  • ACCE272047 - update product update ACCE272047 445.58MB
  • ACCE272048 - update product update ACCE272048 461.30MB
  • ACCE272049 - update product update ACCE272049 477.03MB
  • ACCE272050 - update product update ACCE272050 492.75MB
  • ACCE272051 - update product update ACCE272051 508.48MB
  • ACCE272052 - update product update ACCE272052 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 184937 bytes)

How can I limit the memory usage? I can't set a higher memory limit.