Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt6 Windows slower than Qt6 Ubuntu
QtWS25 Last Chance

Qt6 Windows slower than Qt6 Ubuntu

Scheduled Pinned Locked Moved Solved Qt 6
ubuntuwindows 10 instmsvcgccqt6
47 Posts 5 Posters 7.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jsulm
    13 Feb 2024, 06:13

    @Joe-von-Habsburg You should read more carefully what others write. What @JonB suggested is that you try to get the data with a non Qt application on both platforms to see whether the behaviour is the same or not...

    J Offline
    J Offline
    Joe von Habsburg
    wrote on 13 Feb 2024, 07:03 last edited by
    #14

    @jsulm I used javascript for get request.

    const deneme = async() => {
        while(true){
            var date1 = new Date();
        
            var res = await fetch('http://localhost:54664/sample')
            var data = await res.json();
            console.log("sample len : ",data.samples[0].length)
        
            var date2 = new Date();
        
            var res2 = await fetch('http://localhost:54665/sample')
            var data2 = await res2.json();
            console.log("sample len : ",data2.samples[0].length)
        
            var date3 = new Date();
        
            console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1);
        }
    }
    
    
    deneme();
    

    I saw same times between ubuntu and windows (90ms).
    I think the problem is in windows Qt. Any idea ?

    J 1 Reply Last reply 13 Feb 2024, 07:10
    0
    • J Joe von Habsburg
      13 Feb 2024, 07:03

      @jsulm I used javascript for get request.

      const deneme = async() => {
          while(true){
              var date1 = new Date();
          
              var res = await fetch('http://localhost:54664/sample')
              var data = await res.json();
              console.log("sample len : ",data.samples[0].length)
          
              var date2 = new Date();
          
              var res2 = await fetch('http://localhost:54665/sample')
              var data2 = await res2.json();
              console.log("sample len : ",data2.samples[0].length)
          
              var date3 = new Date();
          
              console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1);
          }
      }
      
      
      deneme();
      

      I saw same times between ubuntu and windows (90ms).
      I think the problem is in windows Qt. Any idea ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 13 Feb 2024, 07:10 last edited by
      #15

      @Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 13 Feb 2024, 07:27
      0
      • J jsulm
        13 Feb 2024, 07:10

        @Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous.

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 13 Feb 2024, 07:27 last edited by
        #16

        ... And you should/must not recreate the QNetworkAcceesManager every time.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        J 2 Replies Last reply 13 Feb 2024, 07:54
        4
        • C Christian Ehrlicher
          13 Feb 2024, 07:27

          ... And you should/must not recreate the QNetworkAcceesManager every time.

          J Offline
          J Offline
          Joe von Habsburg
          wrote on 13 Feb 2024, 07:54 last edited by
          #17

          @Christian-Ehrlicher said in Qt6 Windows slower than Qt6 Ubuntu:

          And you should/must not recreate the QNetworkAcceesManager every time.

          This work for me. Thank you so much :)

          1 Reply Last reply
          0
          • C Christian Ehrlicher
            13 Feb 2024, 07:27

            ... And you should/must not recreate the QNetworkAcceesManager every time.

            J Offline
            J Offline
            Joe von Habsburg
            wrote on 13 Feb 2024, 13:45 last edited by
            #18

            @Christian-Ehrlicher

            I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms.

            QByteArray DataReceiver::getData(int port)
            {
                QString url = QString("http://localhost:%1/sample").arg(port);
                _apiUrl.setUrl(url);
                _request.setUrl(_apiUrl);
                _reply = _manager.get(_request);
                connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                _loop.exec();
                if (_reply->error() == QNetworkReply::NoError) {
                    QByteArray responseData = _reply->readAll();
                    _reply->deleteLater();
                    return responseData;
                } else {
                    QString _error = tr("Error");
                    QString _spectrum_error = tr("Spectrum error.");
                    QMessageBox::critical(nullptr, _error, _spectrum_error);
                    stop();
                }
                _reply->deleteLater();
                return NULL;
            }
            

            Do you know, why it's rising ? What can I do another, after take data ?

            J 1 Reply Last reply 13 Feb 2024, 14:43
            0
            • J Joe von Habsburg
              13 Feb 2024, 13:45

              @Christian-Ehrlicher

              I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms.

              QByteArray DataReceiver::getData(int port)
              {
                  QString url = QString("http://localhost:%1/sample").arg(port);
                  _apiUrl.setUrl(url);
                  _request.setUrl(_apiUrl);
                  _reply = _manager.get(_request);
                  connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                  _loop.exec();
                  if (_reply->error() == QNetworkReply::NoError) {
                      QByteArray responseData = _reply->readAll();
                      _reply->deleteLater();
                      return responseData;
                  } else {
                      QString _error = tr("Error");
                      QString _spectrum_error = tr("Spectrum error.");
                      QMessageBox::critical(nullptr, _error, _spectrum_error);
                      stop();
                  }
                  _reply->deleteLater();
                  return NULL;
              }
              

              Do you know, why it's rising ? What can I do another, after take data ?

              J Offline
              J Offline
              Joe von Habsburg
              wrote on 13 Feb 2024, 14:43 last edited by
              #19

              @Joe-von-Habsburg I found the reason. Thanks a lot :) <3

              V 1 Reply Last reply 13 Feb 2024, 19:18
              0
              • J Joe von Habsburg
                13 Feb 2024, 14:43

                @Joe-von-Habsburg I found the reason. Thanks a lot :) <3

                V Offline
                V Offline
                Volker75
                wrote on 13 Feb 2024, 19:18 last edited by
                #20

                @Joe-von-Habsburg And what was the reason? Windows defender?

                J 1 Reply Last reply 14 Feb 2024, 07:46
                0
                • V Volker75
                  13 Feb 2024, 19:18

                  @Joe-von-Habsburg And what was the reason? Windows defender?

                  J Offline
                  J Offline
                  Joe von Habsburg
                  wrote on 14 Feb 2024, 07:46 last edited by Joe von Habsburg
                  #21

                  @Volker75 said in Qt6 Windows slower than Qt6 Ubuntu:

                  And what was the reason? Windows defender?

                  another networkmanager.....

                  @Christian-Ehrlicher , @JonB , @jsulm

                  Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data?

                  QByteArray DataReceiver::getData(int port)
                  {
                      QString url = QString("http://localhost:%1/sample").arg(port);
                      _apiUrl.setUrl(url);
                      _request.setUrl(_apiUrl);
                      reply = _manager.get(_request);
                      connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                      _loop.exec();
                      if (reply->error() == QNetworkReply::NoError) {
                          QByteArray responseData = reply->readAll();
                          reply->deleteLater();
                          return  responseData;
                      } else {
                          QString _error = tr("Error");
                          QString _spectrum_error = tr("Spectrum error.");
                          QMessageBox::critical(nullptr, _error, _spectrum_error);
                          stop();
                      }
                      reply->deleteLater();
                      return {};
                  }
                  

                  if I use my code like that :

                  QByteArray DataReceiver::getData(int port)
                  {
                      QString url = QString("http://localhost:%1/sample").arg(port);
                      QUrl _apiUrl(url);
                      QNetworkRequest _request(_apiUrl);
                      QEventLoop _loop;
                      QNetworkAccessManager _manager;
                      QNetworkReply *reply = _manager.get(_request);
                      connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                      _loop.exec();
                      if (reply->error() == QNetworkReply::NoError) {
                          QByteArray responseData = reply->readAll();
                          reply->deleteLater();
                          return  responseData;
                      } else {
                          QString _error = tr("Error");
                          QString _spectrum_error = tr("Spectrum error.");
                          QMessageBox::critical(nullptr, _error, _spectrum_error);
                          stop();
                      }
                      reply->deleteLater();
                      return {};
                  }
                  

                  Memory will not rise but response time slow....

                  J 1 Reply Last reply 14 Feb 2024, 08:44
                  0
                  • J Joe von Habsburg
                    14 Feb 2024, 07:46

                    @Volker75 said in Qt6 Windows slower than Qt6 Ubuntu:

                    And what was the reason? Windows defender?

                    another networkmanager.....

                    @Christian-Ehrlicher , @JonB , @jsulm

                    Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data?

                    QByteArray DataReceiver::getData(int port)
                    {
                        QString url = QString("http://localhost:%1/sample").arg(port);
                        _apiUrl.setUrl(url);
                        _request.setUrl(_apiUrl);
                        reply = _manager.get(_request);
                        connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                        _loop.exec();
                        if (reply->error() == QNetworkReply::NoError) {
                            QByteArray responseData = reply->readAll();
                            reply->deleteLater();
                            return  responseData;
                        } else {
                            QString _error = tr("Error");
                            QString _spectrum_error = tr("Spectrum error.");
                            QMessageBox::critical(nullptr, _error, _spectrum_error);
                            stop();
                        }
                        reply->deleteLater();
                        return {};
                    }
                    

                    if I use my code like that :

                    QByteArray DataReceiver::getData(int port)
                    {
                        QString url = QString("http://localhost:%1/sample").arg(port);
                        QUrl _apiUrl(url);
                        QNetworkRequest _request(_apiUrl);
                        QEventLoop _loop;
                        QNetworkAccessManager _manager;
                        QNetworkReply *reply = _manager.get(_request);
                        connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                        _loop.exec();
                        if (reply->error() == QNetworkReply::NoError) {
                            QByteArray responseData = reply->readAll();
                            reply->deleteLater();
                            return  responseData;
                        } else {
                            QString _error = tr("Error");
                            QString _spectrum_error = tr("Spectrum error.");
                            QMessageBox::critical(nullptr, _error, _spectrum_error);
                            stop();
                        }
                        reply->deleteLater();
                        return {};
                    }
                    

                    Memory will not rise but response time slow....

                    J Offline
                    J Offline
                    JonB
                    wrote on 14 Feb 2024, 08:44 last edited by
                    #22

                    @Joe-von-Habsburg
                    Is the difference due to the QNetworkAccessManager _manager; or to the QNetworkReply *reply = _manager.get(_request);?
                    In the bad case you might connect to reply->destroyed() to make sure it is indeed getting freed.

                    J 1 Reply Last reply 14 Feb 2024, 08:58
                    0
                    • J JonB
                      14 Feb 2024, 08:44

                      @Joe-von-Habsburg
                      Is the difference due to the QNetworkAccessManager _manager; or to the QNetworkReply *reply = _manager.get(_request);?
                      In the bad case you might connect to reply->destroyed() to make sure it is indeed getting freed.

                      J Offline
                      J Offline
                      Joe von Habsburg
                      wrote on 14 Feb 2024, 08:58 last edited by Joe von Habsburg
                      #23

                      @JonB

                      According to my tests, if I rebuild the NetworkManager, my memory usage does not increase. But this time my receiving time is slowing down.

                      If I do not recreate the NetworkManager, my reception time decreases but memory usage increases.

                      connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                      

                      it's work, reply deleted

                      J J 2 Replies Last reply 14 Feb 2024, 09:01
                      0
                      • J Joe von Habsburg
                        14 Feb 2024, 08:58

                        @JonB

                        According to my tests, if I rebuild the NetworkManager, my memory usage does not increase. But this time my receiving time is slowing down.

                        If I do not recreate the NetworkManager, my reception time decreases but memory usage increases.

                        connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                        

                        it's work, reply deleted

                        J Offline
                        J Offline
                        JonB
                        wrote on 14 Feb 2024, 09:01 last edited by
                        #24

                        @Joe-von-Habsburg
                        In that case please replace the second one's QNetworkReply *reply = _manager.get(_request); with the first one's reply = _manager.get(_request); (I assume reply is a member variable, this->reply) and confirm. Then the only difference is the local QNetworkAccessManager _manager versus a class member one.

                        1 Reply Last reply
                        0
                        • J Joe von Habsburg
                          14 Feb 2024, 08:58

                          @JonB

                          According to my tests, if I rebuild the NetworkManager, my memory usage does not increase. But this time my receiving time is slowing down.

                          If I do not recreate the NetworkManager, my reception time decreases but memory usage increases.

                          connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                          

                          it's work, reply deleted

                          J Offline
                          J Offline
                          Joe von Habsburg
                          wrote on 14 Feb 2024, 10:56 last edited by Joe von Habsburg
                          #25

                          @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                          connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);

                          sorry for that. this is work only when I stop my while loop. How can force it ?

                          @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                           void DataReceiver::start()
                           {
                               _connection++;
                               if(_connection > 1)
                                   return;
                           
                               qDebug() << "Starting take data";
                               _takeData = true;
                               while(_takeData){
                                   QDateTime time1 = QDateTime::currentDateTime();
                                   _sample = getData(54664);
                                   QDateTime time3 = QDateTime::currentDateTime();
                                   if(_takeIQData)
                                       _iq = getData(54665);
                                   QDateTime time2 = QDateTime::currentDateTime();
                                   qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time :  << time2 - time1;
                                  emit sendData(_sample, _iq);
                               }
                               qDebug() << "Finished taking data";
                           }
                          
                          

                          @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                          n that case please replace the second one's QNetworkReply *reply = _manager.get(_request); with the first one's reply = _manager.get(_request); (I assume reply is a member variable, this->reply) and confirm. Then the only difference is the local QNetworkAccessManager _manager versus a class member one.

                          I change it.
                          _reply and _manager class member now

                          QByteArray DataReceiver::getData(int port)
                          {
                              QString url = QString("http://localhost:%1/sample").arg(port);
                              QUrl _apiUrl(url);
                              QNetworkRequest _request(_apiUrl);
                              QEventLoop _loop;
                              _reply = _manager.get(_request);
                              connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                              connect(_reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                              _loop.exec();
                              if (_reply->error() == QNetworkReply::NoError) {
                                  QByteArray responseData = _reply->readAll();
                                  _reply->deleteLater();
                                  return  responseData;
                              } else {
                                  QString _error = tr("Error");
                                  QString _spectrum_error = tr("Spectrum error.");
                                  QMessageBox::critical(nullptr, _error, _spectrum_error);
                                  stop();
                              }
                              _reply->deleteLater();
                              return {};
                          }
                          

                          The problem still exists.

                          I think lots of reply are created and they only delete I stop my loop.

                          J 1 Reply Last reply 14 Feb 2024, 11:15
                          0
                          • J Joe von Habsburg
                            14 Feb 2024, 10:56

                            @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                            connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);

                            sorry for that. this is work only when I stop my while loop. How can force it ?

                            @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                             void DataReceiver::start()
                             {
                                 _connection++;
                                 if(_connection > 1)
                                     return;
                             
                                 qDebug() << "Starting take data";
                                 _takeData = true;
                                 while(_takeData){
                                     QDateTime time1 = QDateTime::currentDateTime();
                                     _sample = getData(54664);
                                     QDateTime time3 = QDateTime::currentDateTime();
                                     if(_takeIQData)
                                         _iq = getData(54665);
                                     QDateTime time2 = QDateTime::currentDateTime();
                                     qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time :  << time2 - time1;
                                    emit sendData(_sample, _iq);
                                 }
                                 qDebug() << "Finished taking data";
                             }
                            
                            

                            @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                            n that case please replace the second one's QNetworkReply *reply = _manager.get(_request); with the first one's reply = _manager.get(_request); (I assume reply is a member variable, this->reply) and confirm. Then the only difference is the local QNetworkAccessManager _manager versus a class member one.

                            I change it.
                            _reply and _manager class member now

                            QByteArray DataReceiver::getData(int port)
                            {
                                QString url = QString("http://localhost:%1/sample").arg(port);
                                QUrl _apiUrl(url);
                                QNetworkRequest _request(_apiUrl);
                                QEventLoop _loop;
                                _reply = _manager.get(_request);
                                connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                connect(_reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                                _loop.exec();
                                if (_reply->error() == QNetworkReply::NoError) {
                                    QByteArray responseData = _reply->readAll();
                                    _reply->deleteLater();
                                    return  responseData;
                                } else {
                                    QString _error = tr("Error");
                                    QString _spectrum_error = tr("Spectrum error.");
                                    QMessageBox::critical(nullptr, _error, _spectrum_error);
                                    stop();
                                }
                                _reply->deleteLater();
                                return {};
                            }
                            

                            The problem still exists.

                            I think lots of reply are created and they only delete I stop my loop.

                            J Offline
                            J Offline
                            JonB
                            wrote on 14 Feb 2024, 11:15 last edited by
                            #26

                            @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                            I think lots of reply are created and they only delete I stop my loop.

                            I do not follow this. One reply per _manager.get(_request), and you have checked that is getting destroyed.

                            Supposedly, the only difference now is that in good case you create and destroy a local QNetworkAccessManager _manager each time (hence slower) while in bad case you reuse member variable. Right?

                            In that case can only suggest you try playing with stuff to see if it makes any difference in the bad case. QNAM has a couple of caches you can clear (see docs), try those. Try calling its setAutoDeleteReplies(true). Try making the member variable a QNetworkAccessManager *_manager which you new and deleteLater() or delete and instead create a new one in the member variable each time its destroyed for use next time. That would "emulate" having it as a local variable which gets automatically created & destroyed in the good case.

                            Other than that I am out of ideas. maybe someone expert will comment.

                            J 2 Replies Last reply 14 Feb 2024, 11:46
                            0
                            • J JonB
                              14 Feb 2024, 11:15

                              @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                              I think lots of reply are created and they only delete I stop my loop.

                              I do not follow this. One reply per _manager.get(_request), and you have checked that is getting destroyed.

                              Supposedly, the only difference now is that in good case you create and destroy a local QNetworkAccessManager _manager each time (hence slower) while in bad case you reuse member variable. Right?

                              In that case can only suggest you try playing with stuff to see if it makes any difference in the bad case. QNAM has a couple of caches you can clear (see docs), try those. Try calling its setAutoDeleteReplies(true). Try making the member variable a QNetworkAccessManager *_manager which you new and deleteLater() or delete and instead create a new one in the member variable each time its destroyed for use next time. That would "emulate" having it as a local variable which gets automatically created & destroyed in the good case.

                              Other than that I am out of ideas. maybe someone expert will comment.

                              J Offline
                              J Offline
                              Joe von Habsburg
                              wrote on 14 Feb 2024, 11:46 last edited by
                              #27

                              @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                              One reply per _manager.get(_request), and you have checked that is getting destroyed.

                              I can't delete _reply after get data.

                              _reply->deleteLater();
                              

                              I used connect function, I saw this result: when I stop loop, _replys will be deleted (lots of delete).

                              connect(_reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                              void DataReceiver::replyDeleted()
                              {
                                  qDebug() << "reply deleted.";
                              }
                              

                              Result : 500409cc-80cf-486c-a0d2-cf80d7040a0a-image.png

                              @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                              Supposedly, the only difference now is that in good case you create and destroy a local QNetworkAccessManager _manager each time (hence slower) while in bad case you reuse member variable. Right?

                              Yes you right, if I do not use as local member (_manager), response time slow, but I use as local member, memory leak.

                              @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                              ry calling its setAutoDeleteReplies(true). Try making the member variable a QNetworkAccessManager *_manager which you new and deleteLater()

                              QByteArray DataReceiver::getData(int port)
                              {
                                  QString url = QString("http://localhost:%1/sample").arg(port);
                                  QUrl _apiUrl(url);
                                  QNetworkRequest _request(_apiUrl);
                                  QEventLoop _loop;
                                  _manager = new QNetworkAccessManager();
                                  _manager->setAutoDeleteReplies(true);
                                  _reply = _manager->get(_request);
                                  connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                  connect(_reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);
                                  _loop.exec();
                                  if (_reply->error() == QNetworkReply::NoError) {
                                      QByteArray responseData = _reply->readAll();
                                      _reply->deleteLater();
                                      _manager->deleteLater();
                                      return  responseData;
                                  } else {
                                      QString _error = tr("Error");
                                      QString _spectrum_error = tr("Spectrum error.");
                                      QMessageBox::critical(nullptr, _error, _spectrum_error);
                                      stop();
                                  }
                                  _reply->deleteLater();
                                  return {};
                              }
                              

                              I added them my function, but now slow time and memory leak exist together.

                              @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                              Other than that I am out of ideas. maybe someone expert will comment.

                              Thank you, Anyone can help me, I will be honered.

                              1 Reply Last reply
                              0
                              • J JonB
                                14 Feb 2024, 11:15

                                @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                                I think lots of reply are created and they only delete I stop my loop.

                                I do not follow this. One reply per _manager.get(_request), and you have checked that is getting destroyed.

                                Supposedly, the only difference now is that in good case you create and destroy a local QNetworkAccessManager _manager each time (hence slower) while in bad case you reuse member variable. Right?

                                In that case can only suggest you try playing with stuff to see if it makes any difference in the bad case. QNAM has a couple of caches you can clear (see docs), try those. Try calling its setAutoDeleteReplies(true). Try making the member variable a QNetworkAccessManager *_manager which you new and deleteLater() or delete and instead create a new one in the member variable each time its destroyed for use next time. That would "emulate" having it as a local variable which gets automatically created & destroyed in the good case.

                                Other than that I am out of ideas. maybe someone expert will comment.

                                J Offline
                                J Offline
                                Joe von Habsburg
                                wrote on 14 Feb 2024, 14:05 last edited by Joe von Habsburg
                                #28

                                @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                setAutoDeleteReplies(true)

                                this is crashed my program when I do something.

                                if I do it :

                                _manager.setAutoDeleteReplies(true);
                                

                                memory and speed ok, but program crashed anytime , when I do anything. because reply deleted. why ?

                                J 1 Reply Last reply 14 Feb 2024, 14:28
                                0
                                • J Joe von Habsburg
                                  14 Feb 2024, 14:05

                                  @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                  setAutoDeleteReplies(true)

                                  this is crashed my program when I do something.

                                  if I do it :

                                  _manager.setAutoDeleteReplies(true);
                                  

                                  memory and speed ok, but program crashed anytime , when I do anything. because reply deleted. why ?

                                  J Offline
                                  J Offline
                                  JonB
                                  wrote on 14 Feb 2024, 14:28 last edited by
                                  #29

                                  @Joe-von-Habsburg
                                  I would guess you need to not delete it yourself now (_reply->deleteLater()) since it is being auto-deleted on QNetworkReply::finished?

                                  However if it is being auto-deleted on finished then, because you do _loop.exec(); which waits for finished I would guess you can no longer do _reply->readAll() after the loop, that sounds like crash. You could instead do your data reading inside the loop instead of afterwards.

                                  I really don't know, and have never used any of this stuff :) It was suggestions for narrowing down where the "leakage" might be. But you need someone else if you need someone who truly knows about it.

                                  J 1 Reply Last reply 14 Feb 2024, 14:39
                                  0
                                  • J JonB
                                    14 Feb 2024, 14:28

                                    @Joe-von-Habsburg
                                    I would guess you need to not delete it yourself now (_reply->deleteLater()) since it is being auto-deleted on QNetworkReply::finished?

                                    However if it is being auto-deleted on finished then, because you do _loop.exec(); which waits for finished I would guess you can no longer do _reply->readAll() after the loop, that sounds like crash. You could instead do your data reading inside the loop instead of afterwards.

                                    I really don't know, and have never used any of this stuff :) It was suggestions for narrowing down where the "leakage" might be. But you need someone else if you need someone who truly knows about it.

                                    J Offline
                                    J Offline
                                    Joe von Habsburg
                                    wrote on 14 Feb 2024, 14:39 last edited by
                                    #30

                                    @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                    You could instead do your data reading inside the loop instead of afterwards.

                                    can you give me code example ?

                                    @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                    But you need someone else if you need someone who truly knows about it.

                                    Yes but who will be :D

                                    J 1 Reply Last reply 14 Feb 2024, 14:49
                                    0
                                    • J Joe von Habsburg
                                      14 Feb 2024, 14:39

                                      @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                      You could instead do your data reading inside the loop instead of afterwards.

                                      can you give me code example ?

                                      @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                      But you need someone else if you need someone who truly knows about it.

                                      Yes but who will be :D

                                      J Offline
                                      J Offline
                                      JonB
                                      wrote on 14 Feb 2024, 14:49 last edited by
                                      #31

                                      @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                                      can you give me code example ?

                                      loop.exec() is just a convenience, which blocks till finished(), making your call "synchronous". Instead you can deal with all the data which arrives when it arrives (instead of after finished()) by attaching a slot to _reply->readyRead() signal.

                                      Of course, if you remove _loop.exec() from getData() it will exit while network stuff is still going on, you must not have local variables which go out of scope. You will have to do quite a bit of code reorganizing. And it might be to no avail, I don't know what it will reveal or whether it will solve anything.

                                      J 1 Reply Last reply 15 Feb 2024, 06:21
                                      0
                                      • J JonB
                                        14 Feb 2024, 14:49

                                        @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                                        can you give me code example ?

                                        loop.exec() is just a convenience, which blocks till finished(), making your call "synchronous". Instead you can deal with all the data which arrives when it arrives (instead of after finished()) by attaching a slot to _reply->readyRead() signal.

                                        Of course, if you remove _loop.exec() from getData() it will exit while network stuff is still going on, you must not have local variables which go out of scope. You will have to do quite a bit of code reorganizing. And it might be to no avail, I don't know what it will reveal or whether it will solve anything.

                                        J Offline
                                        J Offline
                                        Joe von Habsburg
                                        wrote on 15 Feb 2024, 06:21 last edited by Joe von Habsburg
                                        #32

                                        @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                        loop.exec() is just a convenience, which blocks till finished(), making your call "synchronous". Instead you can deal with all the data which arrives when it arrives (instead of after finished()) by attaching a slot to _reply->readyRead() signal.

                                        I changed my code.

                                        void DataReceiver::start()
                                        {
                                            if(!_takeData)
                                                return;
                                        
                                            QDateTime time1 = QDateTime::currentDateTime();
                                            getDataSample(); //_sample = getData(54664);
                                            QDateTime time3 = QDateTime::currentDateTime();
                                            if(_takeIQData)
                                                getDataIQ(); //_iq = getData(54665);
                                            QDateTime time2 = QDateTime::currentDateTime();
                                            qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
                                        }
                                        
                                        void DataReceiver::getDataSample()
                                        {
                                            QString url = QString("http://localhost:%1/sample").arg(54664);
                                            QUrl _apiUrl(url);
                                            QNetworkRequest _request(_apiUrl);
                                            _replySample = _managerSample.get(_request);
                                            connect(_replySample, &QNetworkReply::readyRead, this, &DataReceiver::readSample);
                                        }
                                        
                                        void DataReceiver::getDataIQ()
                                        {
                                            QString url = QString("http://localhost:%1/sample").arg(54665);
                                            QUrl _apiUrl(url);
                                            QNetworkRequest _request(_apiUrl);
                                            _replyIQ = _managerIQ.get(_request);
                                            connect(_replyIQ, &QNetworkReply::readyRead, this, &DataReceiver::readIQ);
                                        }
                                        
                                        void DataReceiver::readSample()
                                        {
                                            _sample = _replySample->readAll();
                                            _replySample->deleteLater();
                                            if(!_takeIQData){
                                                emit sendData(_sample, _iq);
                                                _sample.clear();
                                                _iq.clear();
                                                start();
                                            }
                                        
                                        }
                                        
                                        void DataReceiver::readIQ()
                                        {
                                            _iq = _replyIQ->readAll();
                                            _replyIQ->deleteLater();
                                            if(_takeIQData){
                                                emit sendData(_sample, _iq);
                                                _sample.clear();
                                                _iq.clear();
                                                start();
                                            }
                                        }
                                        

                                        After a while crashing :(

                                        J 1 Reply Last reply 15 Feb 2024, 07:16
                                        0
                                        • J Joe von Habsburg
                                          15 Feb 2024, 06:21

                                          @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                                          loop.exec() is just a convenience, which blocks till finished(), making your call "synchronous". Instead you can deal with all the data which arrives when it arrives (instead of after finished()) by attaching a slot to _reply->readyRead() signal.

                                          I changed my code.

                                          void DataReceiver::start()
                                          {
                                              if(!_takeData)
                                                  return;
                                          
                                              QDateTime time1 = QDateTime::currentDateTime();
                                              getDataSample(); //_sample = getData(54664);
                                              QDateTime time3 = QDateTime::currentDateTime();
                                              if(_takeIQData)
                                                  getDataIQ(); //_iq = getData(54665);
                                              QDateTime time2 = QDateTime::currentDateTime();
                                              qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
                                          }
                                          
                                          void DataReceiver::getDataSample()
                                          {
                                              QString url = QString("http://localhost:%1/sample").arg(54664);
                                              QUrl _apiUrl(url);
                                              QNetworkRequest _request(_apiUrl);
                                              _replySample = _managerSample.get(_request);
                                              connect(_replySample, &QNetworkReply::readyRead, this, &DataReceiver::readSample);
                                          }
                                          
                                          void DataReceiver::getDataIQ()
                                          {
                                              QString url = QString("http://localhost:%1/sample").arg(54665);
                                              QUrl _apiUrl(url);
                                              QNetworkRequest _request(_apiUrl);
                                              _replyIQ = _managerIQ.get(_request);
                                              connect(_replyIQ, &QNetworkReply::readyRead, this, &DataReceiver::readIQ);
                                          }
                                          
                                          void DataReceiver::readSample()
                                          {
                                              _sample = _replySample->readAll();
                                              _replySample->deleteLater();
                                              if(!_takeIQData){
                                                  emit sendData(_sample, _iq);
                                                  _sample.clear();
                                                  _iq.clear();
                                                  start();
                                              }
                                          
                                          }
                                          
                                          void DataReceiver::readIQ()
                                          {
                                              _iq = _replyIQ->readAll();
                                              _replyIQ->deleteLater();
                                              if(_takeIQData){
                                                  emit sendData(_sample, _iq);
                                                  _sample.clear();
                                                  _iq.clear();
                                                  start();
                                              }
                                          }
                                          

                                          After a while crashing :(

                                          J Offline
                                          J Offline
                                          Joe von Habsburg
                                          wrote on 15 Feb 2024, 07:16 last edited by
                                          #33

                                          @Joe-von-Habsburg said in Qt6 Windows slower than Qt6 Ubuntu:

                                          After a while crashing :(

                                          I found the reason. Because readReady() sometimes receives incomplete data.

                                          jsulmJ J 2 Replies Last reply 15 Feb 2024, 07:18
                                          0

                                          23/47

                                          14 Feb 2024, 08:58

                                          • Login

                                          • Login or register to search.
                                          23 out of 47
                                          • First post
                                            23/47
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved