Comments (6)
Hi @vikingjs!
ReadableIterableStream
and ConcurrentQueueIterator
do not retain values once they have been consumed.
QueueState
(the class underlying the implementation of Queue
and ConcurrentQueueIterator
) unsets values when they are set to the FiberLocal
. See line 86 in QueueState.php.
It sounds to me as though there might be some other bug causing a memory leak or you're buffering the data read, which of course is going to consume that memory as well.
from byte-stream.
That's good to know. The error I'm getting is Amp\Http\Client\ParseException: Configured body size exceeded:
so I don't know how code outside the stream would cause it. Perhaps I'm not consuming as quickly as I thought I was.
I will slow down the server side to see what that does for the buffer.
I'm tempted to try to parallelize reading off that stream, but occasionally two reads are required to instantiate one resulting object. Do you know a way to manage that? It's a case where a single item written into the stream on the server requires two reads on the client.
from byte-stream.
This seems strange in SizeLimitingReadableStream:
$chunk = $this->source->read($cancellation);
if ($chunk !== null) {
$this->bytesRead += \strlen($chunk);
if ($this->bytesRead > $this->sizeLimit) {
$this->exception = new ParseException(
"Configured body size exceeded: {$this->bytesRead} bytes received, while the configured limit is {$this->sizeLimit} bytes",
HttpStatus::PAYLOAD_TOO_LARGE
);
$this->source->close();
}
}
The body size limit is not applied to the amount of data in the body, but the overall amount read. How do I get out from under the tyranny of this class?
from byte-stream.
The HTTP client has a default body size limit (10MB) which can be configured on the Request
object using setBodySizeLimit()
. This exists to allow completely buffering a response body without worry of consuming too much memory. Since you're streaming the response body, feel free to make this number huge, even just using PHP_INT_MAX
to effectively turn off the size limit.
from byte-stream.
That's basically what I have done now. I was hoping to remove that dang thing from the chain as it adds only negative value, but I can get over it. Thanks for your help!
from byte-stream.
It appears we may have intended a body size of 0 to turn off the limit (e.g. this use), but seems we may want to follow through on that, adding the check elsewhere and skip creating SizeLimitingReadableStream
if it's not necessary.
I wouldn't concern yourself over an extra method call per chunk. There's a lot more CPU going to decompressing the response body.
from byte-stream.
Related Issues (20)
- Low bandwidth v2.0.0-beta.13, v2.0.0-beta.14 HOT 10
- Consider avoiding stream_socket_shutdown HOT 3
- Error in Amp\ByteStream\splitLines()
- Broken symlink in docs HOT 2
- Immediate reads and writes might result in blocking HOT 2
- Modify chunk size on the fly HOT 5
- ResourceOutputStream interrupts writing without consumer giving information what was written/unwritten HOT 11
- Problem writing to stream HOT 6
- InputStreamChain HOT 3
- ResourceOutputStream treats open stream as closed HOT 5
- Can cause infinite loop in caller code HOT 2
- Invalid watcher issue in ResourceInputStream
- LineReader custom delimiter HOT 2
- Ability to read particular length from stream HOT 4
- Assertion fail: Trying to read from a previously fclose()'d resource (Windows) HOT 3
- Add InputStream::close
- Add CancellationToken to InputStream::read
- The url inside the composer.json should be in their secure version? HOT 2
- ReadableResourceStream::read() length should reattempt a read if less data is returned? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from byte-stream.