3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Service { public $class; public function __construct($class) { $this->class = $class; } } class Container { public $services = array(); } $start = memory_get_usage(); $container = new Container(); for ($i = 0; $i < 1000; $i++) { $container->services[] = new Service('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service objects: '.$delta, PHP_EOL; $start = memory_get_usage(); $container = new Container(); for ($i = 0; $i < 1000; $i++) { $container->services[] = array('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service arrays: '.$delta;
Output for 7.0.0 - 7.1.0
Memory usage of 1000 service objects: 124976 Memory usage of 1000 service arrays: 320000
Output for 5.6.0 - 5.6.28
Memory usage of 1000 service objects: 304928 Memory usage of 1000 service arrays: 175960
Output for 5.5.0 - 5.5.38
Memory usage of 1000 service objects: 304936 Memory usage of 1000 service arrays: 175944
Output for 5.4.10 - 5.4.45
Memory usage of 1000 service objects: 304936 Memory usage of 1000 service arrays: 175936
Output for 5.4.0 - 5.4.9
Memory usage of 1000 service objects: 304952 Memory usage of 1000 service arrays: 175928
Output for 5.3.11 - 5.3.29
Memory usage of 1000 service objects: 529112 Memory usage of 1000 service arrays: -47968
Output for 5.3.0 - 5.3.10
Memory usage of 1000 service objects: 529160 Memory usage of 1000 service arrays: -48016
Output for 5.2.10 - 5.2.17
Memory usage of 1000 service objects: 513264 Memory usage of 1000 service arrays: -47976
Output for 5.2.7 - 5.2.9
Memory usage of 1000 service objects: 514264 Memory usage of 1000 service arrays: -23416
Output for 5.2.3 - 5.2.6
Memory usage of 1000 service objects: 514288 Memory usage of 1000 service arrays: -23440
Output for 5.2.2
Memory usage of 1000 service objects: 514168 Memory usage of 1000 service arrays: -23336
Output for 5.2.1
Memory usage of 1000 service objects: 513792 Memory usage of 1000 service arrays: -41920
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/2hign on line 18
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/2hign 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/2hign 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/2hign on line 5
Process exited with code 255.