Groups | Blog | Home
all groups > c# > june 2004 >

c# : memory usage of .net application


sean
6/16/2004 11:36:50 PM
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,
Jon Skeet [C# MVP]
6/17/2004 8:27:09 AM
[quoted text, click to view]

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.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Morten Wennevik
6/17/2004 9:14:34 AM
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.

--
Happy coding!
AddThis Social Bookmark Button