Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

What happens when WindowState =Minimized ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grigol Avetikov - 01 Apr 2005 12:11 GMT
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
Herfried K. Wagner [MVP] - 01 Apr 2005 12:40 GMT
"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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.