3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php gc_enable(); 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 scKF3
Output for 7.2.0
string(10) "14.837.384" string(10) "16.785.408" string(9) "1.434.760" string(10) "12.582.912" string(10) "14.837.416" string(10) "16.785.408" string(9) "1.434.760" string(10) "12.582.912"
Output for 7.1.0, 7.1.7
string(10) "14.800.944" string(10) "16.785.408" string(9) "1.398.320" string(10) "12.582.912" string(10) "14.800.976" string(10) "16.785.408" string(9) "1.398.320" string(10) "12.582.912"
Output for 7.1.5 - 7.1.6
string(10) "14.802.888" string(10) "16.785.408" string(9) "1.400.264" string(10) "12.582.912" string(10) "14.802.920" string(10) "16.785.408" string(9) "1.400.264" string(10) "12.582.912"
Output for 7.0.0 - 7.0.20
string(10) "14.801.008" string(10) "16.785.408" string(9) "1.398.384" string(10) "12.582.912" string(10) "14.801.040" string(10) "16.785.408" string(9) "1.398.384" string(10) "12.582.912"
Output for 5.6.7 - 5.6.28
string(10) "34.803.168" string(10) "35.651.584" string(9) "8.553.896" string(10) "22.282.240" string(10) "34.819.592" string(10) "35.651.584" string(9) "8.553.896" string(10) "27.262.976"
Output for 5.5.24 - 5.5.35
string(10) "34.803.144" string(10) "35.651.584" string(9) "8.553.864" string(10) "22.020.096" string(10) "34.819.576" string(10) "35.651.584" string(9) "8.553.864" string(10) "27.000.832"
Output for 5.4.10 - 5.4.45
string(10) "34.803.672" string(10) "35.651.584" string(9) "8.554.352" string(10) "22.282.240" string(10) "34.820.072" string(10) "35.651.584" string(9) "8.554.352" string(10) "28.311.552"
Output for 5.4.0 - 5.4.9
string(10) "34.803.608" string(10) "35.651.584" string(9) "8.554.344" string(10) "22.282.240" string(10) "34.819.896" string(10) "35.651.584" string(9) "8.554.344" string(10) "26.738.688"
Output for 5.3.11 - 5.3.29
string(10) "59.215.752" string(10) "60.030.976" string(9) "8.964.736" string(10) "13.631.488" string(10) "59.234.520" string(10) "60.293.120" string(9) "8.964.736" string(10) "13.893.632"
Output for 5.3.0 - 5.3.10
string(10) "59.215.656" string(10) "60.030.976" string(9) "8.964.600" string(10) "13.893.632" string(10) "59.234.536" string(10) "60.293.120" string(9) "8.964.600" string(10) "14.155.776"
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function gc_enable() in /in/dcFX2 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/dcFX2 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/dcFX2 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/dcFX2 on line 5
Process exited with code 255.