8000 Component/Console/Output/BufferedOutput buffer memory overflow · Issue #39156 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Component/Console/Output/BufferedOutput buffer memory overflow #39156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wenjy opened this issue Nov 24, 2020 · 0 comments · Fixed by #39160
Closed

Component/Console/Output/BufferedOutput buffer memory overflow #39156

wenjy opened this issue Nov 24, 2020 · 0 comments · Fixed by #39160

Comments

@wenjy
Copy link
wenjy commented Nov 24, 2020

protected function doWrite(string $message, bool $newline)

see laravel issue: laravel/framework#35340

Steps To Reproduce:

use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;

include __DIR__ . "/../vendor/autoload.php";

$input = new StringInput('test');
$output = new ConsoleOutput();

$style = new SymfonyStyle($input, $output);

$str = 'teststr';
$num = 26843546;//(128 << 20) / 5; "tstr\r\n"  php memory 128M

for ($i =0;$i<$num;$i++) {
    $style->writeln($str);
}

echo 'success';

PR: #26863

Need to call bufferedOutput->fetch

chalasr added a commit that referenced this issue Nov 25, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[Console] Use a partial buffer in SymfonyStyle

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39156
| License       | MIT
| Doc PR        | -

Symfony style needs to buffer output in order to get the last 2 chars in order to prepend Block.

By using a `BufferedOutput` symfony bufferize everything while it not needed.

This PR adds a new `TrimmedBufferOutput` that keep only the N last chars.

Commits
-------

18fca29 Use a partial buffer in SymfonyStyle
@chalasr chalasr closed this as completed Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0