3v4l.org

run code in 200+ PHP versions simultaneously
<?php class NonLeakingClass { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } class NonLeakingClass2 { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } function test($x){ $ret = []; for($i=0;$i<(1022/2)*$x;$i++){ $ret[] = new NonLeakingClass(); $ret[] = new NonLeakingClass2(); } return $ret; } for ($h = 1; $h < 5; $h++) { echo "test $h \n\n"; var_dump(memory_get_usage(false)); $a = test($h); unset($a); gc_collect_cycles(); var_dump(memory_get_usage(false)); } exit;
based on lV6mL

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
test 1 int(391984) int(391984) test 2 int(391984) int(400176) test 3 int(400176) int(416560) test 4 int(416560) int(416560)
Output for Arrow functions
test 1 int(351816) int(351816) test 2 int(351816) int(360008) test 3 int(360008) int(376392) test 4 int(376392) int(376392)
Output for Object typehint
test 1 int(351800) int(351800) test 2 int(351800) int(359992) test 3 int(359992) int(376376) test 4 int(376376) int(376376)
Output for Array change keys
test 1 int(351896) int(351896) test 2 int(351896) int(360088) test 3 int(360088) int(376472) test 4 int(376472) int(376472)
Output for Lexical anon
test 1 int(352480) int(352480) test 2 int(352480) int(360672) test 3 int(360672) int(377056) test 4 int(377056) int(377056)

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page