memory leak fix for PHP 5.4.6