3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $j = 1; var_dump(memory_get_usage()); $tipi = array_fill(0, 10000, 'php-internal'); var_dump(memory_get_usage()); //内存没有发生暴增, 没有复制, 只是引用 $tipi_copy = $tipi; var_dump(memory_get_usage()); //内存没有发生暴增, 没有复制, 仍然只是引用 foreach($tipi_copy as $value){ $j += count($value); } var_dump(memory_get_usage()); //内存发生暴增, 发生复制, 不在引用 $tipi_copy[0] = "php-internals-tmp"; var_dump(memory_get_usage());
Output for 7.1.0
int(348072) int(876544) int(876544) int(876544) int(1404984)
Output for 7.0.0 - 7.0.14
int(348104) int(876576) int(876576) int(876576) int(1405016)
Output for hhvm-3.10.0 - 3.12.0
int(2097152) int(2097152) int(2097152) int(2097152) int(2097152)
Output for 5.6.0 - 5.6.28
int(219064) int(1230472) int(1230560) int(1230648) int(2241928)
Output for 5.5.0 - 5.5.36
int(219064) int(1230480) int(1230568) int(1230656) int(2241936)
Output for 5.4.10 - 5.4.45
int(219584) int(1231000) int(1231088) int(1231176) int(2242456)
Output for 5.4.0 - 5.4.9
int(219056) int(1230472) int(1230560) int(1230648) int(2241928)
Output for 5.3.11 - 5.3.29
int(622872) int(1634320) int(1634424) int(1634520) int(2645840)
Output for 5.3.0 - 5.3.10
int(622568) int(1634016) int(1634120) int(1634216) int(2645536)
Output for 5.2.10 - 5.2.17
int(80504) int(1091960) int(1092064) int(1092160) int(2103480)
Output for 5.2.7 - 5.2.9
int(81232) int(1093672) int(1093872) int(1223280) int(2105208)
Output for 5.2.4 - 5.2.6
int(81552) int(1094008) int(1094208) int(1223616) int(2105544)
Output for 5.2.3
int(81552) int(1094008) int(1094208) int(1094208) int(2105568)
Output for 5.2.2
int(79448) int(1091912) int(1092112) int(1092112) int(2103472)
Output for 5.2.1
int(79448) int(1091384) int(1091584) int(1091584) int(2102944)
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/F0fC4 on line 4
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_usage() in /in/F0fC4 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: memory_get_usage() in /in/F0fC4 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_usage() in /in/F0fC4 on line 4