Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Executing QProcess in QThread: memory leak
Forum Updated to NodeBB v4.3 + New Features

Executing QProcess in QThread: memory leak

Scheduled Pinned Locked Moved Unsolved General and Desktop
79 Posts 7 Posters 19.0k Views 2 Watching
  • 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by sitesv
    #50

    UPD:
    I found the cause of this situation. Ip's are not available. How to set a timeout for the process execution in this case?

    jsulmJ KroMignonK 2 Replies Last reply
    0
    • sitesvS sitesv

      UPD:
      I found the cause of this situation. Ip's are not available. How to set a timeout for the process execution in this case?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #51

      @sitesv Why do you actually use a local event loop? You can implement this functionality without blocking your app with a local event loop.
      Also, you terminate that event loop already in the first lambda call (when the first process finishes)...

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

      sitesvS 1 Reply Last reply
      0
      • jsulmJ jsulm

        @sitesv Why do you actually use a local event loop? You can implement this functionality without blocking your app with a local event loop.
        Also, you terminate that event loop already in the first lambda call (when the first process finishes)...

        sitesvS Offline
        sitesvS Offline
        sitesv
        wrote on last edited by
        #52

        @jsulm Local EventLoop was recommended before. Could you please advise something?

        jsulmJ 1 Reply Last reply
        0
        • sitesvS sitesv

          @jsulm Local EventLoop was recommended before. Could you please advise something?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #53

          @sitesv You know how many processes you started. So, count how many processes already finished (inside the lambda). And as soon as all processes finished you can check success_count and emit the signal. All this can be done inside lambda.

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

          1 Reply Last reply
          0
          • sitesvS sitesv

            UPD:
            I found the cause of this situation. Ip's are not available. How to set a timeout for the process execution in this case?

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #54

            @sitesv said in Executing QProcess in QThread: memory leak:

            How to set a timeout for the process execution in this case?

            Have you tried to look at ping parameters (ping --help)

            And I would only wait once, for all pings to be done:

            QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
            int success_count = 0;
            int pingsToDo = ip_list.count();
            QEventLoop l;
            foreach(auto ip, ip_list)
            {
                QProcess ping;
                ping.setProcessChannelMode(QProcess::MergedChannels);
                connect(&ping,
                        QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                        [&l, &ping, &success_count, &pingsToDo]() {
                            --pingsToDo;
                            QString output(ping.readAll());
                            if(output.contains("ttl",Qt::CaseInsensitive)) success_count++;
                            if(!pingsToDo)
                                l.exit();
                        });
                ping.start("/bin/ping", QStringList() << ip << "-c" << "1");
            }
            
            // wait all pings done
            l.exec();
            if(success_count == ip_list.count())
               emit setStatus(true);
            else
               emit setStatus(false);
            m_timer->start();
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            sitesvS 1 Reply Last reply
            1
            • KroMignonK KroMignon

              @sitesv said in Executing QProcess in QThread: memory leak:

              How to set a timeout for the process execution in this case?

              Have you tried to look at ping parameters (ping --help)

              And I would only wait once, for all pings to be done:

              QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
              int success_count = 0;
              int pingsToDo = ip_list.count();
              QEventLoop l;
              foreach(auto ip, ip_list)
              {
                  QProcess ping;
                  ping.setProcessChannelMode(QProcess::MergedChannels);
                  connect(&ping,
                          QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                          [&l, &ping, &success_count, &pingsToDo]() {
                              --pingsToDo;
                              QString output(ping.readAll());
                              if(output.contains("ttl",Qt::CaseInsensitive)) success_count++;
                              if(!pingsToDo)
                                  l.exit();
                          });
                  ping.start("/bin/ping", QStringList() << ip << "-c" << "1");
              }
              
              // wait all pings done
              l.exec();
              if(success_count == ip_list.count())
                 emit setStatus(true);
              else
                 emit setStatus(false);
              m_timer->start();
              
              sitesvS Offline
              sitesvS Offline
              sitesv
              wrote on last edited by sitesv
              #55

              @KroMignon said in Executing QProcess in QThread: memory leak:

              And I would only wait once, for all pings to be done:

              Wow! Very nice!! Thank you!

              @KroMignon
              UPD: app is freezing on line l.exec() althought l.exit() is done....

              1 Reply Last reply
              0
              • sitesvS Offline
                sitesvS Offline
                sitesv
                wrote on last edited by
                #56

                Guys, how to resolve this?

                KroMignonK 1 Reply Last reply
                0
                • sitesvS sitesv

                  Guys, how to resolve this?

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #57

                  @sitesv said in Executing QProcess in QThread: memory leak:

                  Guys, how to resolve this?

                  Hmm, I think it is a tricky issue. I would start with forcing QueuedConnection, to avoid threading issues:

                  connect(&ping,
                              QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                              [&l, &ping, &success_count, &pingsToDo]() {
                                  ...
                              }, Qt::QueuedConnection);
                  

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  sitesvS 1 Reply Last reply
                  0
                  • KroMignonK KroMignon

                    @sitesv said in Executing QProcess in QThread: memory leak:

                    Guys, how to resolve this?

                    Hmm, I think it is a tricky issue. I would start with forcing QueuedConnection, to avoid threading issues:

                    connect(&ping,
                                QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                [&l, &ping, &success_count, &pingsToDo]() {
                                    ...
                                }, Qt::QueuedConnection);
                    
                    sitesvS Offline
                    sitesvS Offline
                    sitesv
                    wrote on last edited by
                    #58

                    @KroMignon said in Executing QProcess in QThread: memory leak:

                    connect(&ping,
                    QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                    &l, &ping, &success_count, &pingsToDo {
                    ...
                    }, Qt::QueuedConnection);

                    'connect' failed again
                    img1.png

                    KroMignonK 2 Replies Last reply
                    0
                    • sitesvS sitesv

                      @KroMignon said in Executing QProcess in QThread: memory leak:

                      connect(&ping,
                      QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                      &l, &ping, &success_count, &pingsToDo {
                      ...
                      }, Qt::QueuedConnection);

                      'connect' failed again
                      img1.png

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by KroMignon
                      #59

                      @sitesv Can you show the code you have written

                      Sorry my fault, should be:

                      connect(&ping,
                              QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                              &l, // receiver!
                              [&l, &ping, &success_count, &pingsToDo]() {
                                  ...
                              }, Qt::QueuedConnection);
                      

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      sitesvS 1 Reply Last reply
                      0
                      • KroMignonK KroMignon

                        @sitesv Can you show the code you have written

                        Sorry my fault, should be:

                        connect(&ping,
                                QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                &l, // receiver!
                                [&l, &ping, &success_count, &pingsToDo]() {
                                    ...
                                }, Qt::QueuedConnection);
                        
                        sitesvS Offline
                        sitesvS Offline
                        sitesv
                        wrote on last edited by
                        #60

                        @KroMignon

                        QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
                            int success_count = 0;
                            int pingsToDo = ip_list.count();
                            QEventLoop l; // used for passive wait until process finished
                            foreach(auto ip, ip_list)
                            {
                                QProcess ping;
                                ping.setProcessChannelMode(QProcess::MergedChannels);
                                connect(&ping,
                                        QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), &l,
                                        [&l, &ping, &success_count, &pingsToDo]() {
                                            --pingsToDo;
                                            QString output(ping.readAll()); // <<<<<<<<<<<<<<<< SIGSEGV Segmentation fault
                                            if(output.contains("ttl",Qt::CaseInsensitive)){
                                                success_count++;
                                            }
                                            if(!pingsToDo){
                                                l.exit();
                                            }
                                        }, Qt::QueuedConnection);
                                ping.start("/bin/ping", QStringList() << ip << "-c" << "1");
                            }
                            l.exec();
                            if(success_count == ip_list.count()) emit setLedStatus(0, 0, true);
                            else                                 emit setLedStatus(0, 0, false);
                        
                            m_timer->start();
                        
                        

                        There is SIGSEGV Segmentation fault on ping.readAll string. :((

                        1 Reply Last reply
                        0
                        • sitesvS sitesv

                          @KroMignon said in Executing QProcess in QThread: memory leak:

                          connect(&ping,
                          QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                          &l, &ping, &success_count, &pingsToDo {
                          ...
                          }, Qt::QueuedConnection);

                          'connect' failed again
                          img1.png

                          KroMignonK Offline
                          KroMignonK Offline
                          KroMignon
                          wrote on last edited by KroMignon
                          #61

                          @sitesv Sorry but I was a little bit confused when I suggest you this code.
                          This cannot work, because QProcess is killed/destroyed at end of the for loop!
                          Should be:

                          QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
                          int success_count = 0;
                          int pingsToDo = ip_list.count();
                          QEventLoop l;
                          foreach(auto ip, ip_list)
                          {
                              auto ping = new QProcess();
                              ping->setProcessChannelMode(QProcess::MergedChannels);
                              connect(ping,
                                      QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                      [&l, ping, &success_count, &pingsToDo]() {
                                          --pingsToDo;
                                          QString output(ping->readAll());
                                          if(output.contains("ttl",Qt::CaseInsensitive))
                                              success_count++;
                                          // free memory
                                          ping->deleteLater();
                                          //  exit event loop after all pings done
                                          if(!pingsToDo)
                                              l.exit();
                                      });
                              ping->start("/bin/ping", QStringList() << ip << "-c" << "1");
                          }
                          
                          // wait all pings done
                          l.exec();
                          

                          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                          1 Reply Last reply
                          0
                          • JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #62

                            @sitesv , @KroMignon
                            I will say one thing.

                            You are writing code which will call QEventLoop::exec(), blocking whatever calls it. It relies on hitting the QEventLoop::exit() statement, which you only have in response to the QProcess::finished signal. If for whatever reason that does not get hit, your event loop will never be exited.

                            I would not write production (or even development) code like this, and certainly not for distribution. It is asking for an "unseen hang" to occur, one day. I would at minimum hook onto QProcess::errorOccurred, maybe stateChanged() too. And I would put in some sort of timer/timeout, so that if something goes badly wrong you get out of the blocking loop (with perhaps an error flag) instead of waiting for Hell to freeze over....

                            KroMignonK 1 Reply Last reply
                            3
                            • JonBJ JonB

                              @sitesv , @KroMignon
                              I will say one thing.

                              You are writing code which will call QEventLoop::exec(), blocking whatever calls it. It relies on hitting the QEventLoop::exit() statement, which you only have in response to the QProcess::finished signal. If for whatever reason that does not get hit, your event loop will never be exited.

                              I would not write production (or even development) code like this, and certainly not for distribution. It is asking for an "unseen hang" to occur, one day. I would at minimum hook onto QProcess::errorOccurred, maybe stateChanged() too. And I would put in some sort of timer/timeout, so that if something goes badly wrong you get out of the blocking loop (with perhaps an error flag) instead of waiting for Hell to freeze over....

                              KroMignonK Offline
                              KroMignonK Offline
                              KroMignon
                              wrote on last edited by
                              #63

                              @JonB said in Executing QProcess in QThread: memory leak:

                              I would not write production (or even development) code like this, and certainly not for distribution. It is asking for an "unseen hang" to occur, one day. I would at minimum hook onto QProcess::errorOccurred, maybe stateChanged() too. And I would put in some sort of timer/timeout, so that if something goes badly wrong you get out of the blocking loop (with perhaps an error flag) instead of waiting for Hell to freeze over....

                              Yes, this is a good advice.

                              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                              sitesvS 1 Reply Last reply
                              1
                              • KroMignonK KroMignon

                                @JonB said in Executing QProcess in QThread: memory leak:

                                I would not write production (or even development) code like this, and certainly not for distribution. It is asking for an "unseen hang" to occur, one day. I would at minimum hook onto QProcess::errorOccurred, maybe stateChanged() too. And I would put in some sort of timer/timeout, so that if something goes badly wrong you get out of the blocking loop (with perhaps an error flag) instead of waiting for Hell to freeze over....

                                Yes, this is a good advice.

                                sitesvS Offline
                                sitesvS Offline
                                sitesv
                                wrote on last edited by sitesv
                                #64

                                @JonB said in Executing QProcess in QThread: memory leak:

                                You are writing code which will call QEventLoop::exec(), blocking whatever calls it. It relies on hitting the QEventLoop::exit() statement, which you only have in response to the QProcess::finished signal. If for whatever reason that does not get hit, your event loop will never be exited.

                                Maybe my first variant was good (QThread + QProcess)?

                                if(!myProcess) myProcess = new QProcess(this);
                                myProcess->start(exe_path, arguments);
                                myProcess->waitForFinished(500);
                                output = myProcess->readAll();
                                output_str = codec->toUnicode(output);
                                output_strlst = output_str.split("\r\n");
                                myProcess->close();
                                ...
                                

                                There is QProcess "waitForFinished" with timeout.
                                The app wasn't freezing with this approach.

                                KroMignonK jsulmJ 2 Replies Last reply
                                0
                                • sitesvS sitesv

                                  @JonB said in Executing QProcess in QThread: memory leak:

                                  You are writing code which will call QEventLoop::exec(), blocking whatever calls it. It relies on hitting the QEventLoop::exit() statement, which you only have in response to the QProcess::finished signal. If for whatever reason that does not get hit, your event loop will never be exited.

                                  Maybe my first variant was good (QThread + QProcess)?

                                  if(!myProcess) myProcess = new QProcess(this);
                                  myProcess->start(exe_path, arguments);
                                  myProcess->waitForFinished(500);
                                  output = myProcess->readAll();
                                  output_str = codec->toUnicode(output);
                                  output_strlst = output_str.split("\r\n");
                                  myProcess->close();
                                  ...
                                  

                                  There is QProcess "waitForFinished" with timeout.
                                  The app wasn't freezing with this approach.

                                  KroMignonK Offline
                                  KroMignonK Offline
                                  KroMignon
                                  wrote on last edited by
                                  #65

                                  @sitesv said in Executing QProcess in QThread: memory leak:

                                  There is QProcess "waitForFinished" with timeout.
                                  The app wasn't freezing with this approach.

                                  Why not, but you have to wait ping finished before starting next.
                                  If it is what you want, then go with it.

                                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                  1 Reply Last reply
                                  0
                                  • sitesvS sitesv

                                    @JonB said in Executing QProcess in QThread: memory leak:

                                    You are writing code which will call QEventLoop::exec(), blocking whatever calls it. It relies on hitting the QEventLoop::exit() statement, which you only have in response to the QProcess::finished signal. If for whatever reason that does not get hit, your event loop will never be exited.

                                    Maybe my first variant was good (QThread + QProcess)?

                                    if(!myProcess) myProcess = new QProcess(this);
                                    myProcess->start(exe_path, arguments);
                                    myProcess->waitForFinished(500);
                                    output = myProcess->readAll();
                                    output_str = codec->toUnicode(output);
                                    output_strlst = output_str.split("\r\n");
                                    myProcess->close();
                                    ...
                                    

                                    There is QProcess "waitForFinished" with timeout.
                                    The app wasn't freezing with this approach.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #66

                                    @sitesv I'm still wondering why you think you need a local event loop...

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

                                    sitesvS 1 Reply Last reply
                                    1
                                    • jsulmJ jsulm

                                      @sitesv I'm still wondering why you think you need a local event loop...

                                      sitesvS Offline
                                      sitesvS Offline
                                      sitesv
                                      wrote on last edited by
                                      #67

                                      @jsulm said in Executing QProcess in QThread: memory leak:

                                      @sitesv I'm still wondering why you think you need a local event loop...

                                      Hi! I have done variant as you recommend. It's working!

                                      void PingTester::doPing(){
                                          QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
                                          int success_count = 0;
                                          int pingsToDo = ip_list.count();
                                          int ipCnt = pingsToDo;
                                          foreach(auto ip, ip_list)
                                          {
                                              QProcess ping;
                                              ping.setProcessChannelMode(QProcess::MergedChannels);
                                              connect(&ping,
                                                      QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                                      [this, &ping, &success_count, &pingsToDo, ipCnt]() {
                                                          --pingsToDo;
                                                          QString output(ping.readAll());
                                                          if(output.contains("ttl",Qt::CaseInsensitive)){
                                                              success_count++;
                                                          }
                                                          if(!pingsToDo){
                                                              if(success_count == ipCnt) emit setStatus(true);
                                                              else                       emit setStatus(false);
                                                              m_timer->start();
                                                          }
                                                      });
                                              ping.start("/bin/ping", QStringList() << ip << "-c" << "1" << "-w" << "1");
                                          }
                                      }
                                      

                                      I made another experiment:

                                      1. Created a QThread
                                      2. In QThread::run() method::
                                      • made a QTimer* object,
                                      • set him as "one shot kind",
                                      • ran QTimer, and in final
                                        * ran QThread::exec() (for run local EventLoop)...
                                      1. There is timer->start() in timeout slot, It executed, but QTimer doesn't start again.

                                      Any ideas?

                                      JonBJ KroMignonK 2 Replies Last reply
                                      0
                                      • sitesvS sitesv

                                        @jsulm said in Executing QProcess in QThread: memory leak:

                                        @sitesv I'm still wondering why you think you need a local event loop...

                                        Hi! I have done variant as you recommend. It's working!

                                        void PingTester::doPing(){
                                            QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
                                            int success_count = 0;
                                            int pingsToDo = ip_list.count();
                                            int ipCnt = pingsToDo;
                                            foreach(auto ip, ip_list)
                                            {
                                                QProcess ping;
                                                ping.setProcessChannelMode(QProcess::MergedChannels);
                                                connect(&ping,
                                                        QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                                        [this, &ping, &success_count, &pingsToDo, ipCnt]() {
                                                            --pingsToDo;
                                                            QString output(ping.readAll());
                                                            if(output.contains("ttl",Qt::CaseInsensitive)){
                                                                success_count++;
                                                            }
                                                            if(!pingsToDo){
                                                                if(success_count == ipCnt) emit setStatus(true);
                                                                else                       emit setStatus(false);
                                                                m_timer->start();
                                                            }
                                                        });
                                                ping.start("/bin/ping", QStringList() << ip << "-c" << "1" << "-w" << "1");
                                            }
                                        }
                                        

                                        I made another experiment:

                                        1. Created a QThread
                                        2. In QThread::run() method::
                                        • made a QTimer* object,
                                        • set him as "one shot kind",
                                        • ran QTimer, and in final
                                          * ran QThread::exec() (for run local EventLoop)...
                                        1. There is timer->start() in timeout slot, It executed, but QTimer doesn't start again.

                                        Any ideas?

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by JonB
                                        #68

                                        @sitesv
                                        I don't know how/whether your issue relates this, but in your code: you set off ping.start(), but QProcess ping; is a local variable in your foreach loop and so immediately goes out of scope (not to mention, you also re-use the same local variable for each time round the loop, overwriting/destroying the previous one). Nothing should work (it might actually "crash"), I don't understand how you say it does.

                                        On top of all of this: I think we've said it already here above, but goodness only knows why you are using a thread, with all the complications that involves? If you want to run a QProcess and the main thread to know when it's finished, it's asynchronous anyway, it would be a whole lot simpler not to have any thread. I think I said this earlier, but up to you.

                                        And finally, while I'm on a roll: I think you are just using a /bin/ping in order to read the textual output, parse it, and see whether something is there/alive. In which case I'd be tempted to just write it myself in Qt instead of running some external command, I would have thought it's only a few lines of code. Your "parsing" of the output is beyond hokey, not even sure what you think it tells you....

                                        1 Reply Last reply
                                        0
                                        • sitesvS sitesv

                                          @jsulm said in Executing QProcess in QThread: memory leak:

                                          @sitesv I'm still wondering why you think you need a local event loop...

                                          Hi! I have done variant as you recommend. It's working!

                                          void PingTester::doPing(){
                                              QStringList ip_list = {"192.168.0.1", "192.168.0.2"};
                                              int success_count = 0;
                                              int pingsToDo = ip_list.count();
                                              int ipCnt = pingsToDo;
                                              foreach(auto ip, ip_list)
                                              {
                                                  QProcess ping;
                                                  ping.setProcessChannelMode(QProcess::MergedChannels);
                                                  connect(&ping,
                                                          QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
                                                          [this, &ping, &success_count, &pingsToDo, ipCnt]() {
                                                              --pingsToDo;
                                                              QString output(ping.readAll());
                                                              if(output.contains("ttl",Qt::CaseInsensitive)){
                                                                  success_count++;
                                                              }
                                                              if(!pingsToDo){
                                                                  if(success_count == ipCnt) emit setStatus(true);
                                                                  else                       emit setStatus(false);
                                                                  m_timer->start();
                                                              }
                                                          });
                                                  ping.start("/bin/ping", QStringList() << ip << "-c" << "1" << "-w" << "1");
                                              }
                                          }
                                          

                                          I made another experiment:

                                          1. Created a QThread
                                          2. In QThread::run() method::
                                          • made a QTimer* object,
                                          • set him as "one shot kind",
                                          • ran QTimer, and in final
                                            * ran QThread::exec() (for run local EventLoop)...
                                          1. There is timer->start() in timeout slot, It executed, but QTimer doesn't start again.

                                          Any ideas?

                                          KroMignonK Offline
                                          KroMignonK Offline
                                          KroMignon
                                          wrote on last edited by
                                          #69

                                          @sitesv said in Executing QProcess in QThread: memory leak:

                                          Hi! I have done variant as you recommend. It's working!

                                          I am not sure this is really working!
                                          I think you have to (re)learn C++ object life cycle.
                                          You create a QProcess local instance in the for loop, this object will be destroyed at loop end.

                                          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                          1 Reply Last reply
                                          1

                                          • Login

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