If you notice that you're program's memory usage is increasing (as observed using ps) while calling the imap functions, calling this function should free that memory.
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
imap_gc — Leert den IMAP-Cache
$imap
, int $flags
) : boolSäubert den Cache von Einträgen eines bestimmtes Typs.
imap
Eine von imap_open() zurückgegebene IMAP-Verbindung.
flags
Der zu löschende Cache. Es kann eine oder eine Kombination der
folgenden Konstanten sein: IMAP_GC_ELT
(Nachrichten-Cacheelemente), IMAP_GC_ENV
(Umschlag
und Textkörper) und IMAP_GC_TEXTS
(Texte).
Gibt bei Erfolg true
zurück. Im Fehlerfall wird false
zurückgegeben.
Beispiel #1 imap_gc()-Beispiel
<?php
$mbox = imap_open("{imap.example.org:143}", "username", "password");
imap_gc($mbox, IMAP_GC_ELT);
?>