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. QProcess::start() Vs QProcess::startDetached()

QProcess::start() Vs QProcess::startDetached()

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 3.1k 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.
  • A Offline
    A Offline
    amitgolhani
    wrote on last edited by
    #1

    Hi,

    I am new in QProcess. Actually, I am confused in "start" and "startDetached" methods of QProcess.
    I have few questions regarding these methods.

    (1) What is the difference between QProcess::start() Vs QProcess::startDetached()?
    (2) Where should use QProcess::start() and where should use QProcess::startDetached()?
    (3) What are the term and conditions of both?
    (4) Which method will better to use in any application?
    (5) Are both methods have any particular situation to use?

    Kindly suggest me...

    Thanks...

    K 1 Reply Last reply
    0
    • A amitgolhani

      Hi,

      I am new in QProcess. Actually, I am confused in "start" and "startDetached" methods of QProcess.
      I have few questions regarding these methods.

      (1) What is the difference between QProcess::start() Vs QProcess::startDetached()?
      (2) Where should use QProcess::start() and where should use QProcess::startDetached()?
      (3) What are the term and conditions of both?
      (4) Which method will better to use in any application?
      (5) Are both methods have any particular situation to use?

      Kindly suggest me...

      Thanks...

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @amitgolhani said in QProcess::start() Vs QProcess::startDetached():

      (1) What is the difference between QProcess::start() Vs QProcess::startDetached()?

      This is a member function vs a static function.

      (2) Where should use QProcess::start() and where should use QProcess::startDetached()?

      The member function will give you access to I/O of the process and other possibilities.

      (3) What are the term and conditions of both?

      Partly a matter of taste as long as you are not interested in controlling the started process from your application.
      When you need access to the started process through your application, you should not use the static version.

      (4) Which method will better to use in any application?
      (5) Are both methods have any particular situation to use?

      Answers already included above

      Vote the answer(s) that helped you to solve your issue(s)

      A 1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        Hi

        1:
        it controls if the process you start is attached to your app (process)
        with start, if you close app, it will delete the started process also.
        with startDetached, you can close app and started process still lives on.
        https://stackoverflow.com/questions/23263805/what-is-the-difference-between-qprocessstart-and-qprocessstartdetached
        2:
        If you want the process to live on after app, then startDetached. else start.
        There might be other use cases so its a bit black & white description.
        3: not sure what you ask here :)
        4:
        Say you application needs to start many process and they should just run regardless of app then
        startDetached is used.
        5: well QProcess::startDetached is more a fire and forget about it.

        So it comes down to what apps needs to do with process.
        If just start it and not talk to it then startDetached else often
        start is used.

        Hope it helps.

        A 1 Reply Last reply
        3
        • K koahnig

          @amitgolhani said in QProcess::start() Vs QProcess::startDetached():

          (1) What is the difference between QProcess::start() Vs QProcess::startDetached()?

          This is a member function vs a static function.

          (2) Where should use QProcess::start() and where should use QProcess::startDetached()?

          The member function will give you access to I/O of the process and other possibilities.

          (3) What are the term and conditions of both?

          Partly a matter of taste as long as you are not interested in controlling the started process from your application.
          When you need access to the started process through your application, you should not use the static version.

          (4) Which method will better to use in any application?
          (5) Are both methods have any particular situation to use?

          Answers already included above

          A Offline
          A Offline
          amitgolhani
          wrote on last edited by
          #4

          @koahnig

          Thanks for prompt response...

          1 Reply Last reply
          0
          • mrjjM mrjj

            Hi

            1:
            it controls if the process you start is attached to your app (process)
            with start, if you close app, it will delete the started process also.
            with startDetached, you can close app and started process still lives on.
            https://stackoverflow.com/questions/23263805/what-is-the-difference-between-qprocessstart-and-qprocessstartdetached
            2:
            If you want the process to live on after app, then startDetached. else start.
            There might be other use cases so its a bit black & white description.
            3: not sure what you ask here :)
            4:
            Say you application needs to start many process and they should just run regardless of app then
            startDetached is used.
            5: well QProcess::startDetached is more a fire and forget about it.

            So it comes down to what apps needs to do with process.
            If just start it and not talk to it then startDetached else often
            start is used.

            Hope it helps.

            A Offline
            A Offline
            amitgolhani
            wrote on last edited by
            #5

            @mrjj

            Thanks for prompt response.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amitgolhani
              wrote on last edited by
              #6

              Hi,

              I have develop a process monitoring tool. I have used QProcess to launch and monitor each processes. This application is working fine. But the memory of this application (Process monitoring tool ) is increasing every 2 to 3 minutes by 2 to 4 MB.

              I have launched each processes of my tool using "QProcess::start()" method. I think, the issue of memory leak is in "QProcess".

              Apart from this, I used "QProcess::startDetached()" instead of "QProcess::start()" method, then I found that there is no any memory leakage. Will the this "QProcess::startDetached()" method better for my tool???

              I found QProcess memory leakage bug in Qt website:
              https://bugreports.qt.io/browse/QTBUG-31036

              I tried above bug example, same memory leakage appears in my machine. Is this bug is not resolved yet???

              How should I handle memory leakage of my process monitoring tool?

              Kindly suggest me??????

              I am using:
              OS: Windows 8.1 (64 Bit)
              QT version: Qt 5.4.0
              Compiler: Microsoft visual studio 2012

              aha_1980A 1 Reply Last reply
              0
              • A amitgolhani

                Hi,

                I have develop a process monitoring tool. I have used QProcess to launch and monitor each processes. This application is working fine. But the memory of this application (Process monitoring tool ) is increasing every 2 to 3 minutes by 2 to 4 MB.

                I have launched each processes of my tool using "QProcess::start()" method. I think, the issue of memory leak is in "QProcess".

                Apart from this, I used "QProcess::startDetached()" instead of "QProcess::start()" method, then I found that there is no any memory leakage. Will the this "QProcess::startDetached()" method better for my tool???

                I found QProcess memory leakage bug in Qt website:
                https://bugreports.qt.io/browse/QTBUG-31036

                I tried above bug example, same memory leakage appears in my machine. Is this bug is not resolved yet???

                How should I handle memory leakage of my process monitoring tool?

                Kindly suggest me??????

                I am using:
                OS: Windows 8.1 (64 Bit)
                QT version: Qt 5.4.0
                Compiler: Microsoft visual studio 2012

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by aha_1980
                #7

                @amitgolhani said in QProcess::start() Vs QProcess::startDetached():

                I found QProcess memory leakage bug in Qt website:
                https://bugreports.qt.io/browse/QTBUG-31036
                I tried above bug example, same memory leakage appears in my machine. Is this bug is not resolved yet???

                Did you read the bugreport? The reporter hisself said: "sorry, I'm using QProcess wrong". Therefore the bug is closed as invalid.

                Regarding your problem: What do you do with the output of your started process? By default, stdout and stderr are stored within QProcess so you can evaluate them.

                If you don't need them, you should call closeWriteChannel and closeReadChannel.

                I hope that is already the solution for your problem.

                Regards.

                Qt has to stay free or it will die.

                A 1 Reply Last reply
                1
                • aha_1980A aha_1980

                  @amitgolhani said in QProcess::start() Vs QProcess::startDetached():

                  I found QProcess memory leakage bug in Qt website:
                  https://bugreports.qt.io/browse/QTBUG-31036
                  I tried above bug example, same memory leakage appears in my machine. Is this bug is not resolved yet???

                  Did you read the bugreport? The reporter hisself said: "sorry, I'm using QProcess wrong". Therefore the bug is closed as invalid.

                  Regarding your problem: What do you do with the output of your started process? By default, stdout and stderr are stored within QProcess so you can evaluate them.

                  If you don't need them, you should call closeWriteChannel and closeReadChannel.

                  I hope that is already the solution for your problem.

                  Regards.

                  A Offline
                  A Offline
                  amitgolhani
                  wrote on last edited by
                  #8

                  @aha_1980

                  Actually, I spiked closeWriteChannel and closeReadChannel in my development. That is the reason, memory was increasing.

                  Now its working fine.

                  Thanks a lot... :)

                  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