On 16/03/16 14:01, Till Oliver Knoll wrote:
I don't think you're supposed to delete qApp

Actually you do need to delete it. Most people don't because after qApp->exec() returns, the program ends anyway. But if you want to have 0 leaks, you need to delete your QApplication instance.

Usually you don't delete qApp directly, but just your instance, but that's the same thing, really:

  int main(int argc, char** argv)
  {
      QApplication app = new QApplication(/* ... */);
      app->exec();
      delete app;
      // or:
      // delete qApp;
      // which does the same thing.
  }

In normal applications, like the above, deleting it is redundant. You're exiting the process, so the environment is going to clean your memory anyway. It's still a memory leak, if you're pedantic about it.

If you're using QApplication in a plugin, deleting qApp is actually mandatory, otherwise you're leaking the qApp instance when the plugin unloads; no one else is going to delete it for you.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to