What happens when WindowState =Minimized ?

  • Thread starter Thread starter Grigol Avetikov
  • Start date Start date
G

Grigol Avetikov

Hi, i found unusal things happening when Program main window is minimized.
I'm writing large programm on C# and having problem whith memory size
allocated bu program.
Every time i use some dialog's ShowDialog() the memory size of process
increases.
But ones i minimize main window memory size decreases significantly (for
example : program that was just loaded whith 2 nonmodal dialogs takes 35 MB,
after Minimize and Restore it becomes 5 MB after restoring comes 8MB).

My questions are :
Which actions are take when window is minimized ?
How can I reproduse these actions in order to decrease used memory size
(Without Minimize & Restore)?
I tried with GC.Collect() it doesnt help.
Please help.. I need it very urgent.
Giga
 
Grigol Avetikov said:
Hi, i found unusal things happening when Program main window is minimized.
I'm writing large programm on C# and having problem whith memory size
allocated bu program.
Every time i use some dialog's ShowDialog() the memory size of process
increases.
But ones i minimize main window memory size decreases significantly (for
example : program that was just loaded whith 2 nonmodal dialogs takes 35
MB, after Minimize and Restore it becomes 5 MB after restoring comes 8MB).

My questions are :
Which actions are take when window is minimized ?

The behavior caused by calling this function is not specific to .NET
applications only. It is a feature of the Windows/Explorer shell. If an
application is minimized, Windows removes the working set memory from the
application by calling the Win32 function 'SetProcessWorkingSetSize':

<URL:http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessworkingsetsize.asp>

Windows supposes that minimized applications will not be used for some time
and this memory will be made available to other processes. When restoring
the window the application gets the memory back:

PRB: An Application's Working Set Is Trimmed When Its Top-Level Window Is
Minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>

This behavior is by design and it doesn't make sense to worry about it.
 
Thanks for fast answer.
It answers much questions.
But still there are :

After Minimize and Restore memore size increases .. but still it's much
less then
It was before minimized and program still works fast.
So is it correct that i can use 'SetProcessWorkingSetSize' to optimise
memory usage ?
If yes do you know some technology of doing it(like calculating minimum
WorkingSetSize needed
to run programm normaly ) ?
Best Regards,
Giga
 
Back
Top