WinForm Memory Management

G

Guest

When I create a winform app (even with no additional code or controls), it
typically takes 7 - 10Mb on startup. An app with 3 forms can take 3x that.
That memory is allocated to the process only until I minimize the window,
which drops it to < 1Mb.

How can I reclaim this memory through code, similar to how minimize does it?
I do not want the user to have to minimize the form manually or watch the
form minimize then reappear.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

When you start .NET application there a more code loaded in the process
beside the lines that you wrote. The process host .NET CLR, framework
libraries.... It allocates memory for the managed heap, etc. Why yout so
worried about the memory consumption? Unless you write programs for small
devices and with nowadays hardware 10M should be out of any concerns.
 
G

Guest

I appreciate your response.

I understand that there are .NET CLR components being loaded on startup.
But why does so much space get allocated and then freed up on minimize? I
would then expect returning the windowstate to normal would reallocate the
space, but it does not.

The primary concern is acceptance from the organizations's architecture and
desktop services teams. They do not want to deploy an application that
appears to be very resource intensive compared to the functionality. And it
is difficult to explain why the memory is freed up on a minimize, and then
not reallocated on a restore. They will not accept the explanation that this
is just the way that .NET works. Is there no method to constrain resource
consumption, or better manage it?




Stoitcho Goutsev (100) said:
When you start .NET application there a more code loaded in the process
beside the lines that you wrote. The process host .NET CLR, framework
libraries.... It allocates memory for the managed heap, etc. Why yout so
worried about the memory consumption? Unless you write programs for small
devices and with nowadays hardware 10M should be out of any concerns.

--

Stoitcho Goutsev (100) [C# MVP]


DotNet said:
When I create a winform app (even with no additional code or controls), it
typically takes 7 - 10Mb on startup. An app with 3 forms can take 3x
that.
That memory is allocated to the process only until I minimize the window,
which drops it to < 1Mb.

How can I reclaim this memory through code, similar to how minimize does
it?
I do not want the user to have to minimize the form manually or watch the
form minimize then reappear.
 

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

Run Minimized - Memory Consumption 1
Win Form memory problem. 2
memory usage 1
datagrid memory leak? 2
vs2005: windows form won't minimize or maximize 1
Memory leak? 4
Virtual Memory 2
Memory ups and downs 3

Top