QNetworkReply readyRead is not called, memory filling to max until crash
-
@Christian-Ehrlicher said in QNetworkReply readyRead is not called, memory filling to max until crash:
Nothing about buffer sizes here
I think it might. When downloading short files, the signal will only be sent once the request is totally complete. I don't know how it works in internal but I wouldn't be surprised that readyRead signal would be fired only once the bytecount in the buffer matches the bytecount declared in the reply's http header.
I don't know if I'm right or wrong, but in that case it would explain why he never received the readyRead signal if he gets a memory overflow before the file is completely downloaded.
@ankou29666 said in QNetworkReply readyRead is not called, memory filling to max until crash:
I think it might. When downloading short files, the signal will only be sent once the request is totally complete. I don't know how it works in internal but I wouldn't be surprised that readyRead signal would be fired only once the bytecount in the buffer matches the bytecount declared in the reply's http header.
No - it's clearly written: "This signal is emitted once every time new data is available for reading from the device's read channel"
-
@ankou29666 said in QNetworkReply readyRead is not called, memory filling to max until crash:
I think it might. When downloading short files, the signal will only be sent once the request is totally complete. I don't know how it works in internal but I wouldn't be surprised that readyRead signal would be fired only once the bytecount in the buffer matches the bytecount declared in the reply's http header.
No - it's clearly written: "This signal is emitted once every time new data is available for reading from the device's read channel"
@Christian-Ehrlicher this statement is obviously wrong.
by the way what do they actually mean by "new data" ? and same about "availability".
-
@Christian-Ehrlicher this statement is obviously wrong.
by the way what do they actually mean by "new data" ? and same about "availability".
@ankou29666 said in QNetworkReply readyRead is not called, memory filling to max until crash:
this statement is obviously wrong.
Ok, no need to discuss further here...
Qt waits for an event from the OS and emits a queued signal readyRead() so it depends on the current OS + CPU usage...
-
@ankou29666 said in QNetworkReply readyRead is not called, memory filling to max until crash:
this statement is obviously wrong.
Ok, no need to discuss further here...
Qt waits for an event from the OS and emits a queued signal readyRead() so it depends on the current OS + CPU usage...
The OP's unmodified code, on my machine with just 16GB of RAM: retrieving a local file:
$ curl -I http://localhost/backup-2022.tar.gz HTTP/1.1 200 OK Server: nginx/1.18.0 (Ubuntu) Date: Tue, 28 Feb 2023 07:53:57 GMT Content-Type: application/octet-stream Content-Length: 15072231424 Last-Modified: Tue, 28 Feb 2023 07:42:03 GMT Connection: keep-alive ETag: "63fdb04b-382600000" Accept-Ranges: bytes- Emits readyRead thousands of times, reads, and discards the data as expected and documented.
- Finishes cleanly
- Barely cracks 1% of RAM used
- Linux Qt 6.4.2 and 5.15.2
Exhausting RAM without completing is environmental, a Windows platform issue, or web server oddity (is it CPU bound for example).
The only time I had a lone readyRead() call was the web server returning an HTTP 403 (PEBKAC).
Initially, downloading multiple times in the same run consumed an extra memory chunk each time because the QNetworkReply is not deleted. Fixing that fixes this growth.
-
@Christian-Ehrlicher this statement is obviously wrong.
by the way what do they actually mean by "new data" ? and same about "availability".
@robsparrow
The results shown by @ChrisW67 under Linux are indeed what would be expected.One thing to check: your earlier Memory usage screenshot from Task Manager > Performance looks like it's showing for whole machine? Can you verify whether that memory is being used by your Qt process versus whether it is attributed to something else, like the OS itself?
-
@robsparrow
The results shown by @ChrisW67 under Linux are indeed what would be expected.One thing to check: your earlier Memory usage screenshot from Task Manager > Performance looks like it's showing for whole machine? Can you verify whether that memory is being used by your Qt process versus whether it is attributed to something else, like the OS itself?
@JonB that wasn't my graphs !!! All I said is I was wondering what the behavior is for big files. Personally I'm not concerned by such file sizes, and haven't yet reached the point where I will have to deal with bigger file sizes (and I'll still be well below RAM quantity anyways).
I have already seen inaccurate documentations ;) so sometimes I take them a little cautiously.
-
@JonB that wasn't my graphs !!! All I said is I was wondering what the behavior is for big files. Personally I'm not concerned by such file sizes, and haven't yet reached the point where I will have to deal with bigger file sizes (and I'll still be well below RAM quantity anyways).
I have already seen inaccurate documentations ;) so sometimes I take them a little cautiously.
@ankou29666 My fault, I meant to address that to the OP @robsparrow, corrected.
-
@ankou29666 My fault, I meant to address that to the OP @robsparrow, corrected.
@JonB its the new forum style at fault here,
@ankou29666 and @robsparrow have the same color back ground image.
It's also the only thing I tend to look at, at first glance at least
-
@JonB its the new forum style at fault here,
@ankou29666 and @robsparrow have the same color back ground image.
It's also the only thing I tend to look at, at first glance at least
-
@J-Hilk
I also find the new behaviour here when typing@...since the forum update confusing.... Though it's probably not to blame for my fault above :) -
Windows 10 Build 19044. CPU - Ryzen 9 4900H.
Tests:
- without "setReadBufferSize()" - each app rerun gives different count of readyRead signals until app starts filling memory until crash - usually 0-3 signals in first 2-5 seconds and then its not responding anymore and memory is filled until crash
- with reply->setReadBufferSize(1024); - readyRead is called many times per second, memory is not filled, everything is fine
Its not making any load on CPU even in test case (1) when memory is filled.
-
Windows 10 Build 19044. CPU - Ryzen 9 4900H.
Tests:
- without "setReadBufferSize()" - each app rerun gives different count of readyRead signals until app starts filling memory until crash - usually 0-3 signals in first 2-5 seconds and then its not responding anymore and memory is filled until crash
- with reply->setReadBufferSize(1024); - readyRead is called many times per second, memory is not filled, everything is fine
Its not making any load on CPU even in test case (1) when memory is filled.
@JonB said in QNetworkReply readyRead is not called, memory filling to max until crash:
@ankou29666 My fault, I meant to address that to the OP @robsparrow, corrected.
no worry, not the first time this happens in this topic (but as this topic is tagged as solved, i think I can reasonably hope this is the last !!!)
@robsparrow said in QNetworkReply readyRead is not called, memory filling to max until crash:
Windows 10 Build 19044. CPU - Ryzen 9 4900H.
Tests:
- without "setReadBufferSize()" - each app rerun gives different count of readyRead signals until app starts filling memory until crash - usually 0-3 signals in first 2-5 seconds and then its not responding anymore and memory is filled until crash
- with reply->setReadBufferSize(1024); - readyRead is called many times per second, memory is not filled, everything is fine
Its not making any load on CPU even in test case (1) when memory is filled.
thanks for the share, that's good to know
-
Windows 10 Build 19044. CPU - Ryzen 9 4900H.
Tests:
- without "setReadBufferSize()" - each app rerun gives different count of readyRead signals until app starts filling memory until crash - usually 0-3 signals in first 2-5 seconds and then its not responding anymore and memory is filled until crash
- with reply->setReadBufferSize(1024); - readyRead is called many times per second, memory is not filled, everything is fine
Its not making any load on CPU even in test case (1) when memory is filled.
@robsparrow has the buffer size to be 1024? Have you tried any other numbers for comparison?