|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-09-22 21:07 UTC] mvorisek at mvorisek dot cz
Description: ------------ see https://3v4l.org/nUFqX including file multiple times is very common usecase and memory should not increase the issue is present when the included file contains an anonymous class, but the class should be not recreated again and again Test script: --------------- if (isset($fromRequire)) { // return; // leaking even if code below is never executed $class = new class() extends \stdClass {}; return; } for ($i = 0; $i < 10 * 1000; $i++) { $fromRequire = true; require __FILE__; if (($i % (1000)) === 0) { gc_collect_cycles(); echo round(memory_get_usage() / (1024 * 1024), 3) . " MiB\n"; } } Expected result: ---------------- reported memory usage should stay below 1 MiB Actual result: -------------- 0.37 MiB 1.152 MiB 1.973 MiB 2.872 MiB 3.614 MiB 4.67 MiB 5.412 MiB 6.155 MiB 6.898 MiB 8.265 MiB PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 16:00:01 2025 UTC |
Even function declaration included multiple times is leaking memory: ``` return; function xxx() {} ``` https://3v4l.org/NOejV