Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6.0, 5.7.0
-
None
-
Mac OS X 10.11.5 (15F34)
Qt Creator 4.0.0
Based on Qt 5.6.0 (Clang 7.0 (Apple), 64 bit)
From revision 605ea627cc
SecureTransport
-
-
158781ff2555fabcb9af6b47c887519ade5aba50
Description
I will be using the term "memory leak" when I mean "unnecessary and unacceptably huge growth in memory usage", the memory actually gets released when the request is finished. TL;DR at the bottom.
In my application I need to setReadBufferSize on a QNetworkReply * and use the readyRead() signal to read data and write it into a file. I'm not reading all the data available, I'm reading it in chunks (sometimes small) and sometimes queue the reads to a later time.
With HTTPS URLs, it often results in huge memory leaks. I attached a small project where the situation is reproducible and I also attached a screencast of one of the runs (it sometimes, very rarely though, can't be reproduced). The executable simply starts a GET requests with an HTTPS URL and reads only 25 bytes from the QNetworkReply* at a time. I tried different values, but it seems like the lesser the value - the better the chances are to reproduce the issue. (There is a default url hardcoded and an ability to provide the url as a positional argument)
Here's the screencast of the Xсode Instruments tool when the attached project is built and run:
https://drive.google.com/file/d/0B7Mr7aUqMlQ0WjJUQmJZNHBwX00/view?usp=sharing
So the allocated memory resizes to twice its size from time to time.
And the "leak", as identified by the Xcode Intstruments, happens somewhere in:
QSslSocketBackendPrivate::transmit()
I also attached a text file "callstack.rtf" with the call stack that I copied from Xcode Instruments.
TL;DR
Reading from QNetworkReply * in a readyRead()-attached slot often results in huge memory leaks when dealing with HTTPS URLs. (Presumably, when reading in small chunks from QNetworkReply's internal buffer). Xcode Instruments blames QSslSocketBackendPrivate::transmit()
If you are going to dig into this, please let me know of a temporary workaround if there is one.
Attachments
Issue Links
- relates to
-
QTBUG-43388 ioGetFromHttpBrokenServer(no-newline) is flaky
- Open