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
{{ message }}
Repository navigation
ext/gd: imageavif() leaks native C heap memory (~1.6 MB per call) bypassing Zend memory manager #25442
Repeated calls to imageavif() in a loop result in a linear, monotonic growth of the process Resident Set Size (VmRSS), leaking approximately 1.5–1.8 MB of native C heap memory per invocation.
Because the leak occurs entirely within native C heap allocations (via libgd / libavif / libaom system malloc), PHP's Zend Memory Manager (memory_get_usage()) remains completely flat at ~2.0 MB, and ini_set('memory_limit', ...) is never triggered.
Calling imagedestroy() immediately after encoding does not free this memory. Furthermore, invoking malloc_trim(0) through FFI after 50 iterations only recovers ~4 MB out of 89 MB allocated, showing that actual unreleased heap allocations remain pinned in the process.
By comparison, identical 50-iteration and 100-iteration loops using imagewebp() and imagejpeg() maintain a rock-solid flat VmRSS (0 bytes leaked).
Over 1,000 iterations, the process climbs by ~1.6 GB. In batch image processing (e.g., CLI workers generating product thumbnails), worker processes balloon until terminated by the Linux Out-Of-Memory (OOM) killer.
But I expected this output instead: VmRSS should stabilize after initial codec/library initialization (as observed with imagewebp(), which stabilizes at ~44.7 MB without further memory growth).
PHP Version
PHP 8.5.12 (cli) (built: Nov 11 2026 06:28:37) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.12, Copyright (c) Zend Technologies
with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies
Also reproduced on:
PHP 8.4.27 (cli) (built: Nov 11 2026 06:49:10) (NTS)
Operating System
Debian GNU/Linux (x86_64), Linux 6.12.38
Underlying libraries linked via ext/gd:
Hi @Bugfunder it had been fixed upstream through this, php had backported it since in the bundled library. The remaining possibility is to reach out your distribution libgd maintainers to backport it because there is no libgd release since 2.3.3. Hope it helps !
Activity
devnexen commentedon Nov 13, 2026
Hi @Bugfunder it had been fixed upstream through this, php had backported it since in the bundled library. The remaining possibility is to reach out your distribution libgd maintainers to backport it because there is no libgd release since 2.3.3. Hope it helps !
Bugfunder commentedon Nov 13, 2026
Thank you @devnexen for the pointer!
Followed up with upstream LibGD (libgd/libgd#1052) and submitted to the Debian package maintainers, now officially tracked under Debian Bug #1153907:
https://bugs.debian.org/1153907