473,396 Members | 1,774 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,396 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 3301
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.