I'm trying to create an application that hangs in the tray and shows the window on demand. This window consumes a lot of memory, so I want to release all my memory when I close the window.
I'm trying to do this in the following way:
QApplication a(argc, argv);
auto trayMenu = new QMenu;
trayMenu->addAction(QIcon::fromTheme("folder"), "Open main window", [] {
auto mainWindow = new MainWindow;
mainWindow->show();
});
QSystemTrayIcon trayIcon(QIcon::fromTheme("folder"));
trayIcon.setContextMenu(trayMenu);
trayIcon.show();
return QApplication::exec();
In the MainWindow constructor, I specified the delete attribute on closing:
setAttribute(Qt::WA_DeleteOnClose);
At the start the application consumes ~5 MB. After opening the window the application consumes ~170 MB. But after the window is closed, the consumption does not change. Also, when I reopen and close the window, the application continues to consume as much memory (nothing changes). Is it possible to completely release all the memory of the window? I'm using Linux.