Run the script in the console with PHPNG to expose the memory bug:
php bug.php
Environment:
Ubuntu 14.04
PHP 5.7.0-dev (cli) (built: Jul 23 2014 12:50:07)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.7.0-dev, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
php.ini is the same as the one in PHP 5.5 with a memory limit at 128MB