i know that in version 4.8 each http request gets its own thread to run ,
im doing links checker app that doing allot of http request in while loop
i notice in the windows task manager that my app is using more then 1600 threads over time and the number never gos down only up until its crash the app . ( i guessing it is the couse ) my question is does QNetworkAccessManager has option to use thread pool ?
or it has option to clean its thread after it finish its http request?

this is the main loop :

Qt Code:
  1. while(!rpm_urlStack->isEmpty())
  2. {
  3. QString url = rpm_urlStack->top();
  4. rpm_urlStack->pop();
  5.  
  6. QString urlForReq(url);
  7.  
  8. bool returnVal = true;
  9. QNetworkRequest request;
  10.  
  11. request.setUrl(QUrl(urlForReq));
  12. request.setRawHeader("User-Agent", USER_AGENT.toUtf8());
  13. request.setRawHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
  14. request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  15. request.setRawHeader("Accept-Language", "en-us,en;q=0.5");
  16. request.setRawHeader("Connection", "Keep-Alive");
  17.  
  18. QEventLoop loop;
  19. reply = m_networkManager->get(request);
  20. connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
  21. loop.exit();
  22. if(!loop.isRunning())
  23. {
  24.  
  25. loop.exec();
  26.  
  27. }
  28.  
  29. RequestFinishedHandler(reply);
  30.  
  31. }
  32.  
  33. RequestFinishedHandler(QNetworkReply *reply)
  34. {
  35.  
  36.  
  37. if (reply->error() > 0) {
  38. QNetworkReply::NetworkError networkError = reply->error();
  39. QString err = reply->errorString();
  40.  
  41.  
  42. }
  43. else {
  44. QVariant vStatusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
  45. QMutexLocker lock(_pMutex); // _pMutex defined as class member
  46. char *buffer;
  47. buffer = getCurrentDateTime();
  48. QTextStream out(m_file);
  49. out << buffer <<" "<< _sCurrentUrl << "\n";
  50. lock.unlock();
  51. if(vStatusCodeV.toInt() == 200)
  52. {
  53. QString ApiResponse;
  54. QByteArray data;
  55. data=reply->readAll();
  56. ApiResponse.append(QString::fromUtf8(data));
  57.  
  58. }
  59.  
  60. }
  61. reply->deleteLater();
  62.  
  63. }
To copy to clipboard, switch view to plain text mode