473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

.NET eats memory.


I am trying to optimize my C# program, but no matter what I try the
application keeps eating memory. I verified all the references and even got
special software to count references. I made sure all the reference count
reaches zero for all the objects that are no longer used. I also call
Dispose as much as possible. Regardless, the memory is not freed. Even if I
force the GC, some memory gets freed but not much.


I believe the memory is taken by the framework itself. Connection pool,
Thread pool or some other resources the framework uses. I have no way to
know where all the memory is, and therefore I have no way to optimize my
application.

Any ideas how I can control the memory under the framework?

Jul 19 '05 #1
2 3299
"Mike Peretz" <m_******@sympatico.ca> wrote in
news:xd******************@news20.bellglobal.com:

I am trying to optimize my C# program, but no matter what I try
the application keeps eating memory. I verified all the
references and even got special software to count references. I
made sure all the reference count reaches zero for all the
objects that are no longer used. I also call Dispose as much as
possible. Regardless, the memory is not freed. Even if I force
the GC, some memory gets freed but not much.

I believe the memory is taken by the framework itself.
Connection pool, Thread pool or some other resources the
framework uses. I have no way to know where all the memory is,
and therefore I have no way to optimize my application.

Any ideas how I can control the memory under the framework?


Mike,

How are you measuring the memory usage?

If you are using Task Manager (TM), then realize that TM doesn't seem
to give an accurate measure of the memory a .Net app uses. In fact,
AFAIK, the algorithm used by TM to calculate memory usage is not
published. This means there's no way to know what the number
reported by TM actually reflects. Total physical memory used? Total
virtual memory used? Both? Maybe it's the *anticipated* amount of
memory TM thinks a .Net app will use, and not the actual memory
usage. Your guess is as good as mine.

If you are developing a desktop C# app, try this experiment. Open
TM. Run your app. Note the memory useage reported by TM. Minimize
your app. Note the memory useage again. Restore your app. Note the
memory usage. On my system, with a small C# app, I get readings like
this:

- app startup = 9.6 MB
- app minimize = 608 K
- app restore = 2.5 MB

This gives me the impression that instead of reporting the actual
memory usage of my .Net app, TM is making some kind of complicated
guess as to how much memory my app *might* need. Again, there's no
way to tell for sure...

My approach is to ignore TM's data and use debugging and profiling
tools instead. .Net comes with several performance counters, and
there are third-party apps - both free and commercial - that can
provide much more accurate info than TM.
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Jul 19 '05 #2
..NET Applications seize all of the memory available to them in 1.x versions
of the .NET Framework. However, if another application needs memory, the
framework gladly gives it up (Hence the small memory footprint when an
application is minimized). The memory footprint of a minimized application
is a more accurate analysis of the amount of memory that your application is
using than the large amount of memory consumed when an application is
maximized.

What memory footprint are you targetting? Are you running into a performance
problem because of the application's large memory usage?

-keen
"Mike Peretz" <m_******@sympatico.ca> wrote in message
news:xd******************@news20.bellglobal.com...

I am trying to optimize my C# program, but no matter what I try the
application keeps eating memory. I verified all the references and even got special software to count references. I made sure all the reference count
reaches zero for all the objects that are no longer used. I also call
Dispose as much as possible. Regardless, the memory is not freed. Even if I force the GC, some memory gets freed but not much.


I believe the memory is taken by the framework itself. Connection pool,
Thread pool or some other resources the framework uses. I have no way to
know where all the memory is, and therefore I have no way to optimize my
application.

Any ideas how I can control the memory under the framework?


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jarek | last post by:
Hi all! I'm optimizing my C++ multi-threaded application (linux). My application consumes huge amout of memory from unknown reason. There are no memory leaks, or other allocation bugs,...
9
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but...
2
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all...
6
by: Max Ivanov | last post by:
I'm playing with pyprocessing module and found that it eats lot's of memory. I've made small test case to show it. I pass ~45mb of data to worker processes and than get it back slightly modified....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...

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.