Ram Hungry?

  • Thread starter Thread starter Mark Harris
  • Start date Start date
M

Mark Harris

Just wondering if anyone else has noticed that C# is fairly ram hungy, or
at least assigns alot of ram?

If you have has anyone developed any strategies to combat it?

- Mark Harris
 
If only we could ask our clients to do that on their production
machines...

Oh right - you mean that compiled & distributed apps developed with C# are
memory-hungry... that's a totally different story...
 
machines...

Oh right - you mean that compiled & distributed apps developed with C#
are
memory-hungry... that's a totally different story...

Any suggestions on how to save one's self from unhappy customers over ram
use?

-- Mark Harris
 
This topic has been pretty well beaten to death on various forums. Suggest
you hunt through some archive posts and review this topic.

The short answer is that what you are likely seeing is not nearly so bad as
it appears. First, the garbage collector frees up objects when it actually
*needs* the memory, not necessarily at the first possible moment it *could*
be freed. Secondly, Window Task Manager does not reflect the freed up
memory right away either. That is why if you minimize a .NET app the Task
Manager will suddenly show a lot more free memory. That is the point at
which (1) Windows decides it's a good time to reclaim free memory and (2)
Task Manager gets notified of that fact.

To determine how much memory is REALLY being used, look at the working set,
not the Task Manager.

--Bob
 
Thanks for the relies guys

You can get the current ram usage with the following code:

GC.GetTotalMemory(false);

Is there anyway to reduce the working set? its showing as 12mb in task
manager yet the actual rame usage is about 246kb...

- Mark
 
Mark Harris said:
Thanks for the relies guys

You can get the current ram usage with the following code:

GC.GetTotalMemory(false);

Is there anyway to reduce the working set? its showing as 12mb in task
manager yet the actual rame usage is about 246kb...


GC.GetTotalMemory(false);
doesn't return the actual ram usage, it returns the GC heap usage, which
only accounts for a (small) part of the working set. The working set is the
number of memory pages actualy mapped to your process space . You shouldn't
control/manage the WS from within your application, this is the task of the
OS memory manager.

Willy.
 
Hi,

I do not agree with this. The smaller app consume around 10MB of ram, this
is not that much of memory, considering than the regular machine has 256 MB

If you application cumsume lot of memory it may be cause of your
application , you may be keeping references to objects and it prevent the GC
to recover that memory.

you should better explain your escenario for further help


cheers,
 
Thanks for the reply,

I am calling 10mb alot of memory, considering the same thing in C/C++ is
much much smaller (around 400-500kb). The servers that this application
will be distributed on will all have at least 1gb of ram, 2gb standard,
but there are alot of ram intensive applications on those servers. So our
clients want to see something with absolutly minimal ram use.

- Mark
 
Back
Top