title: What is the correct way to open and close window/dialog?
body: <p>I'm trying to develop a new program. The work flow looks like this:</p>
  
  <pre><code>Login --&gt; Dashboard (Window with menus) --&gt; Module 1
                                          --&gt; Module 2
                                          --&gt; Module 3
                                          --&gt; Module XXX
  </code></pre>
  
  <p>So, to open Dashboard from Login (a Dialog), I use</p>
  
  <pre><code>Dashboard *d = new Dashboard();
  d-&gt;show(); 
  close(); 
  </code></pre>
  
  <p>In Dashboard, I use these codes to reopen the Login if the user closes the Window (by clicking the 'X')</p>
  
  <pre><code>closeEvent(QCloseEvent *) 
  {
      Login *login = new Login();
      login-&gt;show();
  }
  </code></pre>
  
  <p>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. </p>
  
  <p>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.</p>