-
Notifications
You must be signed in to change notification settings - Fork 166
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
HTTP Client API: High memory consumption when downloading big files #214
Comments
In that case |
@cpq Thank you for you reply! I'm looking for a way to handle big responses "on the fly" so storying everything into file first then re-read it is not the preferred approach. If I understand correctly I need handle NS_RECV event to parse received buffer to catch http headers to recognise when the response body begins and clean received data buffer after each iteration.... Probably, some additional events could be raised by the library, e.g. |
That's correct. The way you describe is pretty complex to implement, cause handler needs to be a state machine. I was describing a simpler way, when handler just saves raw HTTP response into a file, and then parsing is done over the file, something like that:
|
OK. Your sample looks clear and it seems to be I need to implement that state machine on top of the library so the state will be managed by connection instance. That is OK. |
I tried sample http client app to download some big files (about 1 GB) on desktop. While tracking memory usage, I noticed it is constantly growing until the file is downloaded. This happens because the library downloads the entire response into memory first, before
NS_HTTP_REPLY
is arrived.It would be nice to extend the HTTP client API of the library to support downloading big HTTP responses as data chunks to prevent eating all available memory on a device...
The text was updated successfully, but these errors were encountered: