memory usage of .net application

  • Thread starter Thread starter sean
  • Start date Start date
S

sean

Hi,

I notice if I run my application, the Windows Task Manager
shows the application using around 20MB of memory.

However, after I minimized the application and
maximize/restore the application again, the memory usage
dropped to around 5MB.

It seems like only after startup, it uses up to 20MB of
memory and after you minimize it, the memory usage drops.

Anybody knows why this happens? and Is there anyway to
have the program start running with memory usage of 5MB?

Thank you in advance.



regards,
Sean
 
Well, you could do a trick.

In your form's Load event add these lines

this.WindowState = FormWindowState.Minimized;
this.WindowState = FormWindowState.Normal;

The side effect is that it will give the illusion of starting from the taskbar, but will release unused resources used during form creation, or trigger the garbage collector, not sure which.
 
sean said:
I notice if I run my application, the Windows Task Manager
shows the application using around 20MB of memory.

However, after I minimized the application and
maximize/restore the application again, the memory usage
dropped to around 5MB.

It seems like only after startup, it uses up to 20MB of
memory and after you minimize it, the memory usage drops.

Anybody knows why this happens? and Is there anyway to
have the program start running with memory usage of 5MB?

It sounds like you're just going by what task manager is showing, which
is just the working set. There's been a lot of discussion about this in
the newsgroups - do a groups.google.com search on the .NET newsgroups
for "working set" and you'll get loads of hits.
 
Back
Top