Memory usage and dialogs
-
Hi all, I have a problem with dialogs... After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases. I don't know how to free the extra memory that a dialog makes after closing it! please help me... Thank you.
Every new thing you learn,Gives you a new personality.
-
Hi all, I have a problem with dialogs... After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases. I don't know how to free the extra memory that a dialog makes after closing it! please help me... Thank you.
Every new thing you learn,Gives you a new personality.
Call Dispose method of the form. Or just use using block and it will be automatically called for you.
Giorgi Dalakishvili #region signature My Articles / My Latest Article[^] / My blog[^] #endregion
-
Hi all, I have a problem with dialogs... After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases. I don't know how to free the extra memory that a dialog makes after closing it! please help me... Thank you.
Every new thing you learn,Gives you a new personality.
Giorgi's reply is correct, but since this is a C++ board, I'll assume you're using C++/CLI... You should call Dispose on IDisposable-derived objects. More important than releasing memory is releasing unmanaged resources held by the object. In C++/CLI, these are the ways to get Dispose() called on an object (taken right from the docs):
\*If an object created using stack semantics goes out of scope. For more information, see C++ Stack Semantics for Reference Types. \*If an exception is thrown during the object's construction. \*If the object is a member in an object whose destructor is running. \*If you call the delete Operator (C++) on a handle (^ (Handle to Object on Managed Heap)). \*If you explicitly call the destructor.
Using delete is the most natural C++ way IMO...Here's an example:
Form ^frm = gcnew Form(); ... delete frm; // calls Dispose() since Form is IDisposable!
You're still not going to see all memory released using task manager. There will still be many managed objects that will be released when the GC gets around to it. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi all, I have a problem with dialogs... After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases. I don't know how to free the extra memory that a dialog makes after closing it! please help me... Thank you.
Every new thing you learn,Gives you a new personality.
Adding to other replies You can use Stack Semantics to automatically delete object when the scope ends. So don't use handle when creating object. Write like this
Form2 frm;
frm.ShowDialog();When variable goes out of scope, it's distructor will get called automatically.
Navaneeth How to use google | Ask smart questions
-
Hi all, I have a problem with dialogs... After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases. I don't know how to free the extra memory that a dialog makes after closing it! please help me... Thank you.
Every new thing you learn,Gives you a new personality.
What everyone else said, plus:
dSolariuM wrote:
After using ShowDialog() method to show a dialog, memory usage (in Task manager) rises Up about 3 Mega bytes. But after closing that dialog only 1 mega byte of memory releases.
What is going on in that dialog? If code in the dialog is allocating memory or resources then you are responsible for cleaning it up. Simply closing the dialog will NOT free any memory or resources that your code specifically allocates, including the dialog object itself if you allocated it on the heap.
led mike