3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_objects() { $array = array(); for ($i=0; $i<5000; $i++) { $object = new stdClass(); $object->a = rand(); $object->b = rand(); $object->c = rand(); $object->d = rand(); $object->e = rand(); $array[] = $object; } return $array; } $results = array(); for ($i=0; $i<30; $i++) { $results = get_objects(); echo memory_get_usage(true) . "\n"; // assigning empty array fixes the problem // $results = array(); }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
4194304 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456 6291456
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
6291456 7340032 7340032 7602176 7602176 7864320 7864320 8126464 8126464 8388608 8388608 8650752 8650752 8912896 8912896 9175040 9175040 9437184 9437184 9699328 9699328 9961472 9961472 10223616 10223616 10485760 10485760 10747904 10747904 11010048
Output for 5.3.0 - 5.3.29
6815744 8126464 7864320 8388608 8126464 8650752 8388608 8912896 8650752 9175040 8912896 9437184 9175040 9699328 9437184 9961472 9699328 10223616 9961472 10485760 10223616 10747904 10485760 11010048 10747904 11272192 11010048 11534336 11272192 11796480
Output for 5.2.6 - 5.2.17
5767168 6815744 6815744 7077888 7077888 7340032 7340032 7602176 7602176 7864320 7864320 8126464 8126464 8388608 8388608 8650752 8650752 8912896 8912896 9175040 9175040 9437184 9437184 9699328 9699328 9961472 9961472 10223616 10223616 10485760
Output for 5.2.1 - 5.2.5
5767168 6553600 7077888 6815744 7340032 7077888 7602176 7340032 7864320 7602176 8126464 7864320 8388608 8126464 8650752 8388608 8912896 8650752 9175040 8912896 9437184 9175040 9699328 9437184 9961472 9699328 10223616 9961472 10485760 10223616
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/5q6ut on line 24
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_usage() in /in/5q6ut on line 24
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: memory_get_usage() in /in/5q6ut on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_usage() in /in/5q6ut on line 24

preferences:
135.86 ms | 401 KiB | 231 Q