3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php gc_enable(); class x { public $value; public $y; public function __construct($value) { $this->value = $value; $this->y = new y(); } } class y { } $array = array(); for($i = 0; $i < 50000; $i++) { $array[] = new x(md5('Hallo')); } var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; unset($array); var_dump(gc_collect_cycles()) . "\n"; var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n";
based on HZpia
Output for 7.2.0
string(10) "12.730.040" string(10) "14.684.160" int(0) string(9) "1.428.744" string(10) "12.582.912"
Output for 7.1.0, 7.1.7
string(10) "12.693.600" string(10) "14.684.160" int(0) string(9) "1.392.304" string(10) "12.582.912"
Output for 7.1.5 - 7.1.6
string(10) "12.694.672" string(10) "14.684.160" int(0) string(9) "1.393.376" string(10) "12.582.912"
Output for 7.0.0 - 7.0.20
string(10) "12.693.648" string(10) "14.684.160" int(0) string(9) "1.392.352" string(10) "12.582.912"
Output for 5.6.7 - 5.6.28
string(10) "29.874.064" string(10) "30.408.704" int(0) string(9) "8.549.216" string(10) "16.252.928"
Output for 5.5.24 - 5.5.35
string(10) "29.874.064" string(10) "30.408.704" int(0) string(9) "8.549.192" string(10) "16.252.928"
Output for 5.4.10 - 5.4.45
string(10) "29.874.608" string(10) "30.408.704" int(0) string(9) "8.549.688" string(10) "15.728.640"
Output for 5.4.0 - 5.4.9
string(10) "29.874.544" string(10) "30.408.704" int(0) string(9) "8.549.688" string(10) "15.728.640"
Output for 5.3.11 - 5.3.29
string(10) "54.280.800" string(10) "55.050.240" int(0) string(9) "8.955.856" string(10) "10.485.760"
Output for 5.3.0 - 5.3.10
string(10) "54.280.728" string(10) "55.050.240" int(0) string(9) "8.955.720" string(10) "10.485.760"
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function gc_enable() in /in/ILQCK on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ILQCK on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ILQCK on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/ILQCK on line 5
Process exited with code 255.