I'm getting memory exhaustion error when executing mass action on a model with large amount of records. I'm trying to optimize this by setting an limit on the collection, however it seems that the full collection is loaded before the limit is even set. Here's the code that causes the memory exhaustion:
$collection = $this->filter->getCollection($this->collectionFactory->create())->setPageSize(1)->setCurPage(1);
It's inside mass action's controller execute method.
edit: So I guess Magento\Ui\Component\MassAction::getFilterIds()
is at fault as it generates all selected ids inside an array, to later execute sql in statement to filter which model rows need to be used. Not sure if I even can fix it.