How to destroy a dialog when the window of that dialog is closed?
-
So i am showing a dialog this way:
.h file
@private:
preferences *Preferences;@.cpp file
@Preferences = new preferences(this);
Preferences->exec();@but when the user closes the dialog with (X) the ram that this dialog has taken does not decrease,
neither integers (that has been changed before clicking the (X) ) get reseted to their starting value. -
Hi,
@delete preferences;@
after exec ?But in that case, why keep a pointer to it in your class if you want to destroy it right after use ?
You can also do:
@
Preferences preferences;
preferences.exec();
@preferences will get destroyed when going out of scope.
Hope it helps
-
You dialog has "class scope" so when your class holding the pointer is still active, it will keep the dialog in memory. Use a local scope like sGalst says.
Greetz -
u sure when i have
@private:
preferences *Preferences;@its
@ preferences.exec();@and not
@ Preferences.exec();@eitherway i do it, i get always an error like
@error: expected ';' before 'preferences'
@[quote author="SGaist" date="1375712475"]Hi,
@delete preferences;@
after exec ?But in that case, why keep a pointer to it in your class if you want to destroy it right after use ?
You can also do:
@
Preferences preferences;
preferences.exec();
@preferences will get destroyed when going out of scope.
Hope it helps[/quote]
-
WELL IF THIS ISN'T WEIRD
i went with the delete way
i tested with my task manager besides and i saw that memory usage goes up, but doesn't goes down when u close the dialog
BUT, when i did the same while recording with "Record my desktop" the memory went down immediatly
PLEASE EXPLAIN ME what is going on :/
Ubuntu 13.04 here -
Sorry for the letter case mixing, my classes name always starts with an upper cased letter (like in Qt).
The memory freed by the application is not always directly returned to the OS and that can have several reasons: reuse of the memory segment, memory page lock etc...