При попытке отправить полезную нагрузку массива из 100К записей в задание Laravel (Horizon и Redis) возникает проблема с памятью:
Allowed memory size of 536870912 bytes exhausted (tried to allocate 77598720 bytes)
Память установлена в 512 МБ.
КодЯ использовал
CreateSmsBroadcast::dispatch($user, $smsBroadcast, iterator_to_array($contacts),
$requestData)->onQueue('create-sms-broadcast');
При передаче полезной нагрузки contacts (iterator)
,
CreateSmsBroadcast::dispatch($user, $smsBroadcast, $contacts, $requestData)
->onQueue('create-sms-broadcast');
затем получаю следующую проблему:
// vendor/laravel/framework/src/Illuminate/Queue/Queue.php
protected function createObjectPayload($job)
{
return [
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
'maxTries' => $job->tries ?? null,
'timeout' => $job->timeout ?? null,
'timeoutAt' => $this->getJobExpiration($job),
'data' => [
'commandName' => get_class($job),
'command' => serialize(clone $job), // line of error
],
];
}
Serialization of 'Generator' is not allowed
Я не хочу увеличиватьпамять.Поэтому, пожалуйста, предложите мне, как мне исправить вышеуказанную проблему?