3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } class obj { public $items = array(); public $data; } function subobj($obj, $depth=5) { for($i = 0; $i < 5; $i++) { $obj->items[$i] = new obj; $obj->items[$i]->data = generateRandomString(64); if($depth>1) subobj($obj->items[$i], $depth-1); } } print "Populating object..."; $obj = new obj; for($i = 0; $i < 10; $i++) { subobj($obj); } print "\nSerializing..."; $data = serialize($obj); print "\nLooping...\n"; $iterations = 20000; while($iterations--) { $newstr = unserialize($data); if($iterations % 1000 == 0) print "$iterations: " . sprintf('%0.2f', memory_get_usage()/1024/1024) . "Mb\n"; }
based on 0Gu4r

Abusive script

This script was stopped while abusing our resources

Output for 5.4.0 - 5.4.11, 5.4.13 - 5.6.21, 7.0.0 - 7.0.6
Populating object... Serializing... Looping...
Process exited with code 137.
Output for hhvm-3.12.0
Populating object... Serializing... Looping... 19000: 6.00Mb 18000: 6.00Mb
Process exited with code 137.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.4.12
Populating object...
Process exited with code 137.