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()
In the following output I printed the memory usage after every save.
How can I limit the memory usage? I can't set a higher memory limit.