Problem of memory leak with PHP and queryFontMetrics from Imagick

  Kiến thức lập trình

I’ve been using Imagick etqueryFontMetrics for years for my projects. And for the past few days, I’ve been having memory problems. My PHP code using queryFontMetrics are not returning memory, and so I see server memory increasing until saturation.

I created a little code to test:


$draw = new ImagickDraw();
$draw -> setFont($fontFile);
$draw -> setFontSize($fontSize);

$imagick = new Imagick();
$bbox = $imagick -> queryFontMetrics($draw,$text);  


return $bbox;

I run this code in a loop with 1000 iterations
When I run this code on the php command line, no problem, the memory is completely freed.
But when I run it with Apache, it doesn’t free the memory.
I tested this code on a debian 12 server with php 8.2, apache2 2.4.59, Imagick 3.7.0 and ImageMagick 6.9.11-60.

Is there something I’m doing wrong?
Thanks for your help !

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website