box icon indicating copy to clipboard operation
box copied to clipboard

PhpScoper compactor seems to run into memory leak

Open icanhazstring opened this issue 2 years ago • 3 comments

Bug report

Question Answer
Box version 3.15.0@8923e3c
PHP version 7.4 or 8.0.14
Platform with version Docker Alpine and MacOS
Github Repo - composer-unused/composer-unused

Running latest version if compactor for PHPScoper seems to run into a memory leak. I kept increasing the memory_limit to 3G but this still failed. I also can't seem to figure out where this might happen.

box.json
{
   "base-path": null,
   "output": "build/composer-unused.phar",
   "files": [
       "config/container.php",
       "config/service_manager.php"
   ],
   "compactors": [
       "KevinGH\\Box\\Compactor\\PhpScoper"
   ]
}

Output
± |fix/composer-plugin {7} U:3 ?:2 ✗| → .phive/box compile

   ____
  / __ )____  _  __
 / __  / __ \| |/_/
/ /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 3.15.0@8923e3c 2022-02-04 12:58:25 UTC

// Loading the configuration file                                                                                      
// "/Users/andreas.froemer/Projects/composer-unused/composer-unused/box.json".                                         

🔨  Building the PHAR "/Users/andreas.froemer/Projects/composer-unused/composer-unused/build/composer-unused.phar"

? Registering compactors
 + KevinGH\Box\Compactor\PhpScoper
? Adding main file: /Users/andreas.froemer/Projects/composer-unused/composer-unused/bin/composer-unused
? Adding requirements checker
? Adding binary files
   > No file found
? Auto-discover files? Yes
? Exclude dev files? Yes
? Adding files
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 135168 bytes) in phar:///Users/andreas.froemer/Projects/composer-unused/composer-unused/.phive/box/vendor/amphp/byte-stream/lib/ResourceOutputStream.php on line 237

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 135168 bytes) in phar:///Users/andreas.froemer/Projects/composer-unused/composer-unused/.phive/box/vendor/amphp/byte-stream/lib/ResourceOutputStream.php on line 237
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 29446144 bytes) in phar:///Users/andreas.froemer/Projects/composer-unused/composer-unused/.phive/box/vendor/amphp/serialization/src/NativeSerializer.php on line 21

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 29446144 bytes) in phar:///Users/andreas.froemer/Projects/composer-unused/composer-unused/.phive/box/vendor/amphp/serialization/src/NativeSerializer.php on line 21

icanhazstring avatar Feb 06 '22 08:02 icanhazstring

3G is quite a lot. Out of curiosity could you try with --no-parallel? If it succeeds at least it means the PHP is more likely to be on AMPHP or on Box handling of the parallelism

theofidry avatar Feb 07 '22 15:02 theofidry

Thanks, will try.

icanhazstring avatar Feb 21 '22 11:02 icanhazstring

@theofidry can confirm. Using --no-parallel the compactor works.

icanhazstring avatar Mar 10 '22 07:03 icanhazstring