What is the correct way to open and close window/dialog?
- by mree
I'm trying to develop a new program. The work flow looks like this:
Login --> Dashboard (Window with menus) --> Module 1
--> Module 2
--> Module 3
--> Module XXX
So, to open Dashboard from Login (a Dialog), I use
Dashboard *d = new Dashboard();
d->show();
close();
In Dashboard, I use these codes to reopen the Login if the user closes the Window (by clicking the 'X')
closeEvent(QCloseEvent *)
{
Login *login = new Login();
login->show();
}
With a Task Manager opened, I ran the program and monitor the memory usage. After clicking open Dashboard from Login and closing Dashboard to return to Login, I noticed that the memory keeps increasing about 500 KB. It can goes up to 20 MB from 12 MB of memory usage by just opening and closing the window/dialog.
So, what did I do wrong here ? I need to know it before I continue developing those modules which will definitely eat more memory with my programming. Thanks in advance.