473,783 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# is good for memory usage?

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
9 5204
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
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
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.com wrote in message
news:O5******** *****@TK2MSFTNG P05.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
"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

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
PS

"Pavel A." <pa*****@NOwrit emeNO.comwrote in message
news:47******** *************** ***********@mic rosoft.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

"Pavel A." <pa*****@NOwrit emeNO.comwrote in message
news:47******** *************** ***********@mic rosoft.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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3675
by: rbt | last post by:
Would a Python process consume more memory on a PC with lots of memory? For example, say I have the same Python script running on two WinXP computers that both have Python 2.4.0. One computer has 256 MB of Ram while the other has 2 GB of Ram. On the machine with less Ram, the process takes about 1 MB of Ram. On the machine with more Ram, it uses 9 MB of Ram. Is this normal and expected behavior?
5
6091
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory loss even though I seem to be allocaitng everything; help would be *vastly* appreciated. What am I doing wrong here? I thought I was doing everything correctly (setting things to null, for example) but none of the memory seems to get replaced. ...
2
460
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting the app I load some things into memory for global use of the app but I'll use only 2 starting forms to explain the situation) situation 1 start app with form 1 (72mb memory usage), show form 2 and hide form 1 (89 mb memory usage
6
3278
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that, no memory is lying around. GC reports only 84k of allocations. Starting 5-10 of this apps is going to start taking a considerable amount of memory. Is there a way to reduce this? Tom
2
422
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To test the stuff, I keep to open that child data form for about 10 times. the memory usage shown in GC and task manager both increase. Then I close all those forms. and perform GC collect. The memory usage shown in GC falls, however, the memory...
20
4244
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the memory usage drops to a couple hundred KB. Why? Is there anything I should to to prevent this? I have compiled in release and deactivated all forms of debugging, I think! Thanks, Philip
48
2642
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
6
2204
by: dspfun | last post by:
I would like to analyze my running c-program. What I would like to know for example is the range of the entire address space of my running c-program (memory reserved for/by the running program), starting address and sizes of text (code), stack, heap, bss, constant data, linked in libraries, etc. What are some good ways to extract this kind of information? What (free) tools are the most common ones for displaying this kind of
1
2047
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.