|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-15 08:54 UTC] sniper@php.net
[2005-06-03 15:57 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 05:00:01 2025 UTC |
Description: ------------ When using array keys as variables in the list() function there is a noticiable memory leak. It doesn't seem to matter if you assign values to the array key's before using them in the array. Reproduce code: --------------- //memory leak! while (1) { $out = array(); $arr = array('a','b','c'); list($out['a'], $out['b'], $out['c']) = $arr; } //NO memory leak!! while (1) { $out = array(); $a = &$out['a']; $b = &$out['b']; $c = &$out['c']; $arr = array('a','b','c'); list($a, $b, $c) = $arr; } Expected result: ---------------- Output every 4000 loops # | Memory usage 4000 | 68 KB 8000 | 68 KB 12000 | 68 KB 16000 | 68 KB 20000 | 68 KB 24000 | 68 KB 28000 | 68 KB 32000 | 68 KB 36000 | 68 KB 40000 | 68 KB 44000 | 68 KB 48000 | 68 KB 52000 | 68 KB 56000 | 68 KB 60000 | 68 KB 64000 | 68 KB 68000 | 68 KB 72000 | 68 KB 76000 | 68 KB 80000 | 68 KB 84000 | 68 KB 88000 | 68 KB 92000 | 68 KB 96000 | 68 KB 100000 | 68 KB 104000 | 68 KB 108000 | 68 KB 112000 | 68 KB Actual result: -------------- Output every 4000 loops # | Memory usage 4000 | 349 KB 8000 | 630 KB 12000 | 911 KB 16000 | 1.2 MB 20000 | 1.4 MB 24000 | 1.7 MB 28000 | 2.0 MB 32000 | 2.3 MB 36000 | 2.5 MB 40000 | 2.8 MB 44000 | 3.1 MB 48000 | 3.4 MB 52000 | 3.6 MB 56000 | 3.9 MB 60000 | 4.2 MB 64000 | 4.5 MB 68000 | 4.7 MB 72000 | 5.0 MB 76000 | 5.3 MB 80000 | 5.6 MB 84000 | 5.8 MB 88000 | 6.1 MB 92000 | 6.4 MB 96000 | 6.7 MB 100000 | 6.9 MB 104000 | 7.2 MB 108000 | 7.5 MB 112000 | 7.8 MB