Why my C# helloworld program use 16Mb of RaM ?

  • Thread starter Thread starter elpako
  • Start date Start date
elpako,

There is nothing to fix really. This is the price that is paid for the
services that the Common Language Runtime provides. This memory is used for
things like memory management, garbage collection, etc, etc.

Hope this helps.
 
Hi,

If you search the archives you will see that this is a recurrent question
in the NG.

That is the amount of memory needed for all the managed code you are using,
also IIRC it also include some heap memory that is not being used but is
reserved in case you need it.

Beside all 16MB in today computers is not a big deal after all.

Jon:
Maybe this is something to include in the FAQ , what is the minimun and
why/how it's used.

Cheers,
 
Hi elpako,

I might add that even though the initial memory requirement seem high, adding a bunch of code to your program won't increase the memory usage much (depending of course on the code). Only a small part of that 16mb is actually your program, and most of that is used by the GUI.
 
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us> said:
Jon:
Maybe this is something to include in the FAQ , what is the minimun and
why/how it's used.

Good plan. Any suggested fully worded answers welcome - otherwise I'll
add it to my list of things to do when I have time :)
 
Please be more specific, what memory consumption are you talking about, what
counters are you refering to?
Is your simple "Helloworld" program a console program or a winforms program?

Willy.
 
Your program does not "use" 16Mb of ram. That amount is simply reserved by
..NET for faster memory management. If you fill up your RAM .NET will switch
to a more agressive memory management mode and the amount of memory reported
by the task manager will probably go down a lot, down to 1-2Mb probably.

Etienne Boucher
 
This makes no sense as long as you don't specify what memory space (what
memory perf. counter or taskman counter) you are talking about.
Also, .NET doesn't manage process memory, the CLR only manages it's private
heaps such as the GC heap(s). The process memory is managed by the OS memory
manager.
If you ever have seen a managed application that only takes 1-2 Mb (Working
set) it is because :
1. it is a minimized winforms app. or
2. the system is overloaded and the memory manager has started to trim all
processe's working sets. At this point the system starts thrashing and UI
style applications tend to freeze.

Willy.
 
Back
Top