3v4l.org

run code in 300+ PHP versions simultaneously
<?php gc_enable(); class x { public $value; public function __construct($value) { $this->value = $value; } public function __unset($arg){ echo "Working"; unset($this->value); } } $array = array(); for($i = 0; $i < 50000; $i++) { $array[] = md5('Hallo'); } $x = new x($array); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; unset($array); unset($x); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n";
Output for 7.3.0 - 7.3.12
string(9) "5.692.808" string(9) "6.295.552" string(7) "391.432" string(9) "4.194.304"
Output for 7.2.0 - 7.2.24
string(9) "5.689.096" string(9) "6.295.552" string(7) "387.720" string(9) "4.194.304"
Output for 7.1.25 - 7.1.33
string(9) "5.652.592" string(9) "6.295.552" string(7) "351.216" string(9) "4.194.304"
Output for 7.1.0, 7.1.7
string(9) "5.652.664" string(9) "6.295.552" string(7) "351.288" string(9) "4.194.304"
Output for 7.1.5 - 7.1.6
string(9) "5.653.640" string(9) "6.295.552" string(7) "352.264" string(9) "4.194.304"
Output for 7.0.0 - 7.0.20
string(9) "5.652.712" string(9) "6.295.552" string(7) "351.336" string(9) "4.194.304"
Output for 5.6.7 - 5.6.28
string(10) "10.350.232" string(10) "10.747.904" string(7) "225.472" string(7) "786.432"
Output for 5.5.24 - 5.5.35
string(10) "10.350.232" string(10) "10.747.904" string(7) "225.448" string(7) "786.432"
Output for 5.4.10 - 5.4.45
string(10) "10.350.784" string(10) "10.747.904" string(7) "225.952" string(7) "786.432"
Output for 5.4.0 - 5.4.9
string(10) "10.350.784" string(10) "10.747.904" string(7) "225.960" string(7) "786.432"
Output for 5.3.11 - 5.3.29
string(10) "10.756.568" string(10) "11.272.192" string(7) "631.584" string(9) "1.310.720"
Output for 5.3.0 - 5.3.10
string(10) "10.756.504" string(10) "11.272.192" string(7) "631.448" string(9) "1.572.864"
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Fatal error: Call to undefined function gc_enable() in /in/mDHr0 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/mDHr0 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/mDHr0 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/mDHr0 on line 5
Process exited with code 255.

preferences:
187.8 ms | 401 KiB | 221 Q