|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-12-03 11:29 UTC] mike@php.net
-Assigned To:
+Assigned To: mkoppanen
[2013-12-03 13:01 UTC] mkoppanen@php.net
[2013-12-03 13:02 UTC] mkoppanen@php.net
-Status: Assigned
+Status: Closed
[2013-12-03 13:02 UTC] mkoppanen@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 05:00:01 2025 UTC |
Description: ------------ In Imagick object, there are many method functions contain parameters of type ImagickPixel. For convenience, these parameters allow using a string that represents a color, such as '#000000'. After the end of the function call, the ImagickPixel object generated by these parameters will not be destroyed timely. These resources are only released after the end of the whole request. Test script: --------------- <?php $im = new Imagick(); $im->newImage(100, 100, 'none'); for ($i = 0; $i < 1000; $i++) { $color = sprintf('#%06X', mt_rand(0, 0xffffff)); // NOTICE: If you remove the comment of below line, will not cause a memory leak //$color = new ImagickPixel($color); $im->borderImage($color, 2, 2); if ($i > 0 && ($i % 100) == 0) { echo "[$i] memory: " . number_format(memory_get_usage()) . "\n"; } } Expected result: ---------------- [100] memory: 633,648 [200] memory: 633,648 [300] memory: 633,648 [400] memory: 633,648 [500] memory: 633,648 Actual result: -------------- [100] memory: 677,712 [200] memory: 722,512 [300] memory: 767,312 [400] memory: 812,112 [500] memory: 856,912 [600] memory: 967,248