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";
based on mpluQ
Output for 7.1.0
string(10) "14.793.968" string(10) "16.785.408" string(9) "1.391.344" string(10) "12.582.912"
Output for 7.0.0 - 7.0.14
string(10) "14.794.016" string(10) "16.785.408" string(9) "1.391.392" string(10) "12.582.912"
Output for hhvm-3.12.0
string(10) "12.582.912" string(9) "9.607.352" string(10) "12.582.912" string(7) "311.192"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
string(10) "34.798.056" string(10) "35.651.584" string(9) "8.548.832" string(10) "22.282.240"
Output for 5.5.24 - 5.5.35
string(10) "34.798.056" string(10) "35.651.584" string(9) "8.548.800" string(10) "22.020.096"
Output for 5.4.10 - 5.4.45
string(10) "34.798.608" string(10) "35.651.584" string(9) "8.549.312" string(10) "22.020.096"
Output for 5.4.0 - 5.4.9
string(10) "34.798.608" string(10) "35.651.584" string(9) "8.549.296" string(10) "22.020.096"
Output for 5.3.11 - 5.3.29
string(10) "59.206.832" string(10) "60.030.976" string(9) "8.955.768" string(10) "13.893.632"
Output for 5.3.0 - 5.3.10
string(10) "59.206.504" string(10) "60.030.976" string(9) "8.955.464" string(10) "13.107.200"
Output for 5.2.10 - 5.2.17
string(10) "55.382.288" string(10) "56.360.960" string(9) "6.332.968" string(9) "8.650.752"
Output for 5.2.7 - 5.2.9
string(10) "55.385.192" string(10) "56.360.960" string(9) "6.464.128" string(9) "8.912.896"
Output for 5.2.6
string(10) "55.385.480" string(10) "56.360.960" string(9) "6.464.408" string(9) "8.650.752"
Output for 5.2.3 - 5.2.5
string(10) "55.385.592" string(10) "55.574.528" string(9) "6.464.416" string(10) "10.747.904"
Output for 5.2.2
string(10) "55.383.472" string(10) "55.574.528" string(9) "6.462.376" string(10) "12.058.624"
Output for 5.2.1
string(10) "55.382.336" string(10) "55.574.528" string(9) "6.364.048" string(9) "8.126.464"
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/cf4GC 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/cf4GC 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/cf4GC 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/cf4GC on line 5
Process exited with code 255.