Skip to content

Commit

Permalink
Optimize memory consumption of Amp\ByteStream\pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Oct 11, 2017
1 parent d60ba03 commit 5f0665f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/functions.php
Expand Up @@ -24,7 +24,9 @@ function pipe(InputStream $source, OutputStream $destination): Promise {

while (($chunk = yield $source->read()) !== null) {
$written += \strlen($chunk);
yield $destination->write($chunk);
$writePromise = $destination->write($chunk);
$chunk = null; // free memory
yield $writePromise;
}

return $written;
Expand Down

0 comments on commit 5f0665f

Please sign in to comment.