3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php #gc_disable(); class x { private $value; private $y; public function __construct($value) { $this->value = $value; $this->y = new y(); } } class y { } $array = array(); $objects = array(); for($i = 0; $i < 50000; $i++) { $value = md5('Hallo'); $objects[] = new x($value); $array[] = $value; } var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; unset($array); unset($objects); unset($value); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; $array = array(); $objects = array(); for($i = 0; $i < 50000; $i++) { $value = md5('Hallo'); $objects[] = new x($value); $array[] = $value; } var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; unset($array); unset($objects); unset($value); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.'));
based on cf4GC
Output for 7.1.0
string(10) "14.800.464" string(10) "16.785.408" string(9) "1.397.840" string(10) "12.582.912" string(10) "14.800.496" string(10) "16.785.408" string(9) "1.397.840" string(10) "12.582.912"
Output for 7.0.0 - 7.0.14
string(10) "14.800.528" string(10) "16.785.408" string(9) "1.397.904" string(10) "12.582.912" string(10) "14.800.560" string(10) "16.785.408" string(9) "1.397.904" string(10) "12.582.912"
Output for hhvm-3.12.0
string(10) "12.582.912" string(9) "9.608.872" string(10) "12.582.912" string(7) "312.712" string(10) "14.680.064" string(9) "9.608.872" string(10) "14.680.064" string(7) "312.712"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
string(10) "34.802.776" string(10) "35.651.584" string(9) "8.553.464" string(10) "21.495.808" string(10) "34.818.936" string(10) "35.651.584" string(9) "8.553.464" string(10) "27.787.264"
Output for 5.5.24 - 5.5.35
string(10) "34.802.728" string(10) "35.651.584" string(9) "8.553.432" string(10) "21.757.952" string(10) "34.818.984" string(10) "35.651.584" string(9) "8.553.432" string(10) "28.049.408"
Output for 5.4.10 - 5.4.45
string(10) "34.803.224" string(10) "35.651.584" string(9) "8.553.944" string(10) "21.757.952" string(10) "34.819.504" string(10) "35.651.584" string(9) "8.553.944" string(10) "27.000.832"
Output for 5.4.0 - 5.4.9
string(10) "34.803.232" string(10) "35.651.584" string(9) "8.553.944" string(10) "21.757.952" string(10) "34.819.472" string(10) "35.651.584" string(9) "8.553.944" string(10) "26.476.544"
Output for 5.3.11 - 5.3.29
string(10) "59.215.456" string(10) "60.030.976" string(9) "8.964.448" string(10) "13.631.488" string(10) "59.234.416" string(10) "60.293.120" string(9) "8.964.448" string(10) "14.680.064"
Output for 5.3.0 - 5.3.10
string(10) "59.215.144" string(10) "60.030.976" string(9) "8.964.144" string(10) "13.369.344" string(10) "59.233.944" string(10) "60.293.120" string(9) "8.964.144" string(10) "14.155.776"
Output for 5.2.10 - 5.2.17
string(10) "55.391.056" string(10) "56.360.960" string(9) "6.341.744" string(9) "8.912.896" string(10) "55.401.208" string(10) "56.360.960" string(9) "6.341.744" string(9) "8.912.896"
Output for 5.2.7 - 5.2.9
string(10) "55.393.936" string(10) "56.360.960" string(9) "6.472.880" string(9) "8.650.752" string(10) "55.408.840" string(10) "56.360.960" string(9) "6.472.896" string(9) "8.650.752"
Output for 5.2.6
string(10) "55.394.312" string(10) "56.360.960" string(9) "6.473.224" string(9) "9.175.040" string(10) "55.408.896" string(10) "56.360.960" string(9) "6.473.216" string(9) "9.437.184"
Output for 5.2.3 - 5.2.5
string(10) "55.394.296" string(10) "55.574.528" string(9) "6.473.200" string(10) "10.485.760" string(10) "55.408.824" string(10) "55.574.528" string(9) "6.473.240" string(10) "10.485.760"
Output for 5.2.2
string(10) "55.392.176" string(10) "55.574.528" string(9) "6.471.080" string(10) "12.058.624" string(10) "55.406.832" string(10) "55.574.528" string(9) "6.471.104" string(10) "13.107.200"
Output for 5.2.1
string(10) "55.391.128" string(10) "55.574.528" string(9) "6.372.824" string(9) "9.699.328" string(10) "55.392.400" string(10) "55.574.528" string(9) "6.372.800" string(10) "10.485.760"
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/YRpjV on line 26
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/YRpjV 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/YRpjV 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/YRpjV on line 5
Process exited with code 255.