Hello, I have some code I wanted to make sure I have no memory leaks in it so I ran it on my mac and opened activity monitor to see how much memory it was using, then I kept opening new windows(Editor class mentioned in code below) and closing it, and the memory usage increased when I opened them and didn't decrease as I closed. I tried the same thing in top using terminal to get the same result. Is it some lack of knowledge on my behalf on how activity monitor, top and even memory usage works? is it normal? or is there a leak in the code below

P.S. The Editor class allocates nothing dynamically (at least not more than child widgets and variables that were suppose to be disposed after the class is deleted right? ).

add_editor (when a new window is opened):

Qt Code:
  1. void MainControl::add_editor(int mode)
  2. {
  3. int i=0;
  4. QPointer<Editor> *editor_aux=new QPointer<Editor> [editor_n+1];
  5.  
  6. while(i<editor_n)
  7. {
  8. editor_aux[i]=editor_array[i];
  9. i++;
  10. }
  11.  
  12. editor_aux[i]=new Editor(i,mode);
  13. set_editor_conenctions(editor_aux[i]);
  14.  
  15. delete[] editor_array;
  16.  
  17. editor_array=editor_aux;
  18. editor_n++;
  19.  
  20. if(editor_array[i]->start_response==2)
  21. {
  22. del_editor(editor_array[i]->id);
  23. }
  24. }
To copy to clipboard, switch view to plain text mode 

del_editor (when the window is closed):

Qt Code:
  1. void MainControl::del_editor(int id_arg)
  2. {
  3.  
  4. if(editor_n>1)
  5. {
  6. int i=0;
  7. int a=0;
  8.  
  9. QPointer<Editor> *editor_aux=new QPointer<Editor>[editor_n-1];
  10.  
  11. while(i<editor_n)
  12. {
  13. if(editor_array[i]->id==id_arg)
  14. {
  15. unset_editor_conenctions(editor_array[i]);
  16. delete editor_array[i];
  17. }else{
  18. editor_aux[a]=editor_array[i];
  19. a++;
  20. }
  21. i++;
  22. }
  23.  
  24. delete[] editor_array;
  25.  
  26. editor_array=editor_aux;
  27. editor_n--;
  28. }
  29.  
  30. //This below is not needed because when the last window is closed the program closes
  31. /*
  32.   if(editor_n==1){
  33.   editor_n=0;
  34.   delete editor_array[0];
  35.   }
  36.   */
  37. }
To copy to clipboard, switch view to plain text mode