By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,631 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,631 IT Pros & Developers. It's quick & easy.

C# is good for memory usage?

P: n/a
Hi,

Anyone suffers from the high memory usage of C# in windows applications? Is
there a solution for that problem? Thanks...
Oct 18 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Adam,

What kind of memory usage are you observing? When I start an empty
windows application it consumes more than 8MB (as shown on the vm usage
column in task manager). That's perfectly normal.

Brian

Adam Right wrote:
Hi,

Anyone suffers from the high memory usage of C# in windows applications? Is
there a solution for that problem? Thanks...
Oct 18 '06 #2

P: n/a
Hello Adam,

How do u profile you app to get the memory usage?

ARHi,
AR>
ARAnyone suffers from the high memory usage of C# in windows
ARapplications? Is there a solution for that problem? Thanks...
AR>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Oct 18 '06 #3

P: n/a
How high is high?

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Adam Right" <ad**@right.comwrote in message
news:O5*************@TK2MSFTNGP05.phx.gbl...
Hi,

Anyone suffers from the high memory usage of C# in windows applications?
Is there a solution for that problem? Thanks...

Oct 18 '06 #4

P: n/a
"Brian Gideon" wrote:
When I start an empty
windows application it consumes more than 8MB (as shown on the vm usage
column in task manager). That's perfectly normal.
Empty app uses 8 MB? it's a hog.

I've just tried a very small C# console app on XP-64. It takes 13 MB!
On that machine:
Windows Explorer uses 32 MB
wmiprvse - 7.5 MB
Most of system tasks are under 8 MB.

Isn't this a bit worrying?

--PA

Oct 18 '06 #5

P: n/a

Pavel A. wrote:
Isn't this a bit worrying?
Pavel,

Maybe, but since it's not uncommon to have 2000MB on a system it
represents a very small percentage. Plus, since the OS has already
allocated that memory to the GC object creation should be faster than
it would be otherwise.

Brian

Oct 19 '06 #6

P: n/a
PS

"Pavel A." <pa*****@NOwritemeNO.comwrote in message
news:47**********************************@microsof t.com...
"Brian Gideon" wrote:
>When I start an empty
windows application it consumes more than 8MB (as shown on the vm usage
column in task manager). That's perfectly normal.

Empty app uses 8 MB? it's a hog.

I've just tried a very small C# console app on XP-64. It takes 13 MB!
On that machine:
Windows Explorer uses 32 MB
wmiprvse - 7.5 MB
Most of system tasks are under 8 MB.

Isn't this a bit worrying?
At todays memory prices that is costing you about $2. I would be worrying!

Oct 19 '06 #7

P: n/a

"Pavel A." <pa*****@NOwritemeNO.comwrote in message
news:47**********************************@microsof t.com...
| "Brian Gideon" wrote:
| When I start an empty
| windows application it consumes more than 8MB (as shown on the vm usage
| column in task manager). That's perfectly normal.
|
| Empty app uses 8 MB? it's a hog.
|
| I've just tried a very small C# console app on XP-64. It takes 13 MB!
| On that machine:
| Windows Explorer uses 32 MB
| wmiprvse - 7.5 MB
| Most of system tasks are under 8 MB.
|
| Isn't this a bit worrying?
|

Not at all, who tells you that Explorer written in C# would use that much
more? (say 48MB)
The same for wmiprvse, which is a do nothing service as long as you are
using WMI from a client application, I've seen this service consuming >
300MB.
The point is that managed applications have a larger "base memory footprint"
when compared to native applications, this is the result of the CLR loading
a set of initial assemblies and the GC heap. A "complex" console application
won't take that much more than 8 -10MB, what really take memory are the data
structures (the objects allocated from the heap), and this is where the
problem is.
The framework makes it easy to over-consume, it doesn't force you to think
about memory consumption when selecting your containers, this is
fundamentally different from low level code like C where you are forced to
think about "efficient data structure usage" because you have to define them
yourself. Using C++ and STL containers tend toward over-consumption as well,
but as most C++ programmers have a C background, they have the natural
reflection to think about efficiency when selecting containers and
algorithms.
Note that I don't mean to say that you can author an application in managed
code that is as efficient when it comes to memory consumption as it would
have been written in C, you can't, you will always consume at least a few MB
more.
There is the managed environment (GC heap, large framework libraries)
overhead and the "everything is an object" overhead you need to accept, if
you can't, you have selected the wrong development platform and you need to
go back to unmanaged, but be prepared to spend a hell of a time to think
about efficient memory allocation/de-allocation, not to mention the
algorithms and the implementation of the functionality available in the
framework.

Willy.


Oct 19 '06 #8

P: n/a
PRP

Isn't this a bit worrying?
Looks like, not a worrying fact for newer version of frameworks.

Empty application built using framework 1.1 took 14 MB in my system.
and it is 15 MB for 2.0

Oct 19 '06 #9

P: n/a
It all depends on your goal. Once you have one .Net application
running there are shared system resources loaded that all other .net
apps will use. As previously stated tehre is a base memory footprint
that will be larger than native applications, but a negligible one. If
only a few megs of ram is a problem on your system you should look into
offloading some of the apps and/or beefing up the system.

..Net is not meant to be the most resource effecient framework. It is
meant for rapid business application development. You give up a little
resource management and control for a huge increase in the development
time effeciencies. If you need a very effecient program, .Net is not
the way to go...go with a native language like C. By the way, C# and
VB both use the CLR so memory usage will be the same for either one.
Adam Right wrote:
Hi,

Anyone suffers from the high memory usage of C# in windows applications? Is
there a solution for that problem? Thanks...
Oct 19 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.