Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Process] currently not suitable for running processes with large output #17390

Copy link
Copy link
Closed
@avindra

Description

@avindra
Issue body actions

By default, PHP uses a memory_limit of 128M.

Since Symfony/Process stores all output in private $stdout; and private $stderr;, this means that as soon as the output hits 128MB, your PHP script using Symfony/Process will fatally error out with:

[15-Jan-2016 06:31:02 America/New_York] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 131862121 bytes) in /app/myapp/vendor/symfony/process/Process.php on line 815

You can test this pretty quickly by just doing this (assuming you have GNU Coreutils installed):

require("vendor/autoload.php");
use Symfony\Component\Process\Process;

$process = new Process('yes "Hello"');
$process->setTimeout(172800);
$process->run(function ($type, $buffer) {
        // do nothing
});

Unfortunately, we assumed that Symfony/Process was already using a temporary buffer for closures, and saw this issue in production. To mitigate the issue for now, we bumped up our memory_limit, but ideally this should be fixed in Symfony itself.

Since the upper limit on a PHP string itself is 2GB, this also means that Symfony/Process will currently die when the buffer reaches 2GB, no matter what. Here's a sample of that error

[15-Jan-2016 10:16:05 America/New_York] PHP Fatal error:  String size overflow in /app/myapp/vendor/symfony/process/Process.php on line 799

In my opinion, registering closure to run should mean that the entire buffer should not be stored in memory.

Please share your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.