The app is memory leaking, so as a temporary solution I would check how much memory it takes, kill the process and restart the app.
Is there any easy way to do that?
Thank you
The app is memory leaking, so as a temporary solution I would check how much memory it takes, kill the process and restart the app.
Is there any easy way to do that?
Thank you
You should fix the memory leak. Any way if you want to restart your application, you can use QProcess::startDetached
to run an instance of your application in a new process and detach from it. After that you should exit the application.
This will restart your application :
QProcess process;
process.startDetached("myApp",QStringList());
qApp->quit();
Here myApp
is the name of the executable file of the application. On Windows it can be myApp.exe
.
You could override new and delete to keep allocation statistics for the program and then when a threshold is reached based on available mem, abort(). Then in an external script you could restart.
Also see the excellent gimli monitor, here: https://bitbucket.org/wez/gimli/wiki/Monitor
To restart application by itself, try:
#include <QApplication>
#include <QProcess>
...
// restart:
qApp->quit();
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());