You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A long-running script which fetches and processes messages with attachments from a mailbox with this IMAP package results eventually in a 'memory size of ... bytes exhausted'.
I think this has something to do with the fetched attachments. It seems that these attachments somehow are never released from memory?
A workaround is to set manually the attachments to an empty collection after the attachments are processed.
Code to duplicate the bug (be sure to have emails with attachments in the mailbox)
Package version: 5.5.0
PHP: 8.1.x
$inboxFolder = $client->getFolder('inbox');
while (true) {
echo 'Memory usage: ' . memory_get_usage() . PHP_EOL;
$messages = $inboxFolder
->messages()
->all()
->limit(1)
->get();
// Process the messages
}
Workaround
$inboxFolder = $client->getFolder('inbox');
while (true) {
echo 'Memory usage: ' . memory_get_usage() . PHP_EOL;
$messages = $inboxFolder
->messages()
->all()
->limit(1)
->get();
// Process the messages
// Workaround to fix memory issue
$messages->each(
function ($message) {
$message->setAttachments(AttachmentCollection::make([]));
}
);
}
Am I doing something wrong? Or is there a memory leak?
Thanks in advance!
PS: It seems like this package is abandoned?
The text was updated successfully, but these errors were encountered:
A long-running script which fetches and processes messages with attachments from a mailbox with this IMAP package results eventually in a 'memory size of ... bytes exhausted'.
I think this has something to do with the fetched attachments. It seems that these attachments somehow are never released from memory?
A workaround is to set manually the attachments to an empty collection after the attachments are processed.
Code to duplicate the bug (be sure to have emails with attachments in the mailbox)
Package version: 5.5.0
PHP: 8.1.x
Workaround
Am I doing something wrong? Or is there a memory leak?
Thanks in advance!
PS: It seems like this package is abandoned?
The text was updated successfully, but these errors were encountered: