|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-12 12:43 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Package: *General Issues
+Package: Variables related
-Assigned To:
+Assigned To: cmb
[2021-07-12 12:43 UTC] cmb@php.net
[2021-07-12 12:52 UTC] lyrixx at lyrixx dot info
[2021-07-12 13:04 UTC] nikic@php.net
-Status: Duplicate
+Status: Wont fix
[2021-07-12 13:04 UTC] nikic@php.net
[2023-06-26 08:05 UTC] gerefo6485 at aramask dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 00:00:01 2025 UTC |
Description: ------------ When one require a PHP script, that unserialize some data with an instance of DateTime in it, a memory leak occurs Test script: --------------- <?php class Foobar { public function __construct( // If this property is removed => No leak public DateTime $d, ) { } } for ($i=0; $i < 10000; $i++) { $foobar = new Foobar(new \DateTime()); // 1. Leak when "require" is involved $file = '/tmp/test-serialized.php'; file_put_contents($file, sprintf("<?php return unserialize(base64_decode('%s'));\n", base64_encode(serialize($foobar)))); $o = require $file; // 2. No leak in this case // unserialize(serialize($foobar)); if ($i % 1000 === 0) { printf("%.2fMb\n", memory_get_usage() / 1024 / 1024); } } Expected result: ---------------- 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb 0.38Mb Actual result: -------------- 0.38Mb 0.66Mb 0.90Mb 1.23Mb 1.47Mb 1.87Mb 2.11Mb 2.36Mb 2.60Mb 3.16Mb