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