PHP: Speicherplatzproblem bei imagecreate() o. ä.

Mit PHP stößt man manchmal an seine Grenzen. Ich habe gerade an einem kleinen Skript gebastelt, dass mir hochgeladene Bilder auf eine vernünftige Bildgröße reduziert und automatisch Vorschaubilder erzeugt. Das Skript iteriert also durch ein Verzeichnis.
Leider stieß ich damit an ein Speicherlimit:

Fatal error: Allowed memory size of xxx bytes exhausted at (null):0 (tried to allocate xxx bytes) in /xxx.php on line x

war die Fehlermeldung, die mir das Skript auswarf. Die Ursache war schnell gefunden: Nach jedem IMAGECREATE (bzw. ImageCreateFromJPEG()) hatte ich die Bilddaten nicht aus dem Speicher entfernt.
Abhilfe schafft hier der Befehl

      imagedestroy($im);

wobei $im das Bildhandle ist, das man zuvor über ImageCreateFromJPEG() erhalten hat.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Seiten

Sonstiges