Memory consumption in the .NET framework

  • Thread starter Thread starter Michael Hoehne
  • Start date Start date
M

Michael Hoehne

Hi,

this may be a simple question and I'm sure it's answered somewhere in the
docs, but I haven't found it so far.

When running a simple .NET application, Task Manager reports that it needs
about 10MB RAM. Depending on what libraries are used, this may be more or
less. This is what I expect for the first time, because the .NET framework
libraries are loaded into memory.

Now, when starting the same app several times, Task Manager reports 10MB RAM
usage for each started process, which I don't understand. I have two
explanations for it:

1. Task Manager does not report the correct memory usage
2. The .NET framework libraries are loaded into each process

So far, I haven't cared about it, but I'm developing a product consisting
out of some standalone applications, Office Addins, Smart Tags, Smart
Documents, Local Web Services running an Office Research Provider and so on,
so 5 - 10 processes will be started. If the .NET Framework is loaded into
each of these processes, it will need 100MB of RAM or even more just for
copies of the Framework.

Is that a correct assumption? If yes, is there any compiler or linker switch
to share the same instance of the .NET Framework?

Thanks
Michael
 
Hi Michael,

This was asked yesterday in the csharp NG, basically 10 Mb is around the
minimun that a .net app will consume, apart than the .net libraries it may
be due that the GC reserve memory in advance, so that when you create new
instance of objects it does not have to call the win32 API to get more
memory.

It would be great if somebody could dissect a hello word program and see
how the memory is used, but I have not found it yet.


cheers,
 
Ignacio,

thanks for your answer. Though I don't like it, cause I see many questions
from our customers coming asking, why their machine is using 100MB more than
before. I doubt that they're satisfied when telling them that this is for
performance reasons.

Thanks anyway. If you find your hello world program, please post it here.

Thanks again
Michael
 
The extra memory isn't really used, just reserved. If the memory fills up
..NET will release the extra memory.

Etienne Boucher
 
Hi Michael,

Well, I have that reserved for when I have spare time ( not in the
foresight future :( )

Are y our customer seeing any degradation because of that? IF not it's
fine.

Regarding the memory used, well if the memory is "empty" is like it's not
there. there is no point in having a big chunk of memory empty, consuming
energy and doing nothing productive, a MUCH better approach is having the
memory used as much as possible either with buffers, temp data or (as in
..NET ) simply reserved. Now the trick is to have it in such a way that when
a process need it the OS can release this used memory with the littler
overhead compared with just assign it. The most efficient this process is,
the better use of memory you get.

Now, I'm not very sure how XP (or another version) handle this.

Cheers,
 
Back
Top