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" <giga@gtm.com.ge> schrieb:
> 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
[quoted text clipped - 7 lines]
> 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.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Grigol Avetikov - 01 Apr 2005 13:01 GMT
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
> "Grigol Avetikov" <giga@gtm.com.ge> schrieb:
>> Hi, i found unusal things happening when Program main window is
[quoted text clipped - 27 lines]
>
> This behavior is by design and it doesn't make sense to worry about it.
Mehdi - 01 Apr 2005 13:30 GMT
> 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 ?
Michael McIntyre has written a very good article about this topic: "T h e
M e m o r y M y s t e r y ".
http://getdotnetco.web101.discountasp.net/GdncStore/free/Articles/The%20Memory%2
0Mystery.htm
It may answer some of your questions