memory usage of .net application

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
 
M

Morten Wennevik

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.
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top