473,378 Members | 1,522 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,378 software developers and data experts.

Large memory footprint of dotnet application

Hello all

We are developing a large dotnet application, which includes ~ 120
assemblies. (total size of all binaries is ~ 20MB). Our application
also references the following dotnet assemblies: System,System.XML,
System.Windows.Forms, System.Drawing, System.Data,
System.Design. We use dotnet framework 1.1

During initialization, the application scans a directory and loads the
assemblies (using Assembly.LoadFrom). It then scans all types in the
single module in the assembly (using GetModules and Module.GetTypes),
and registers them in application collections by identifying the
properties of each class using reflection.

During the initialization process the memory footprint (both private
bytes and working set) rises to about 220MB, when
#Bytes in all heaps' perfmon counter shows 30MB. This occurs when the
assemlies are scanned, not when they are loaded. The high footprint
causes page faults when the application executes on
some of the target platforms, which has only 256M memory.

To try to account for the 190MB not in the managed heaps, we tried to
estimate the size fo the assemblies in memory when loading. We
pre-jitted the assemblies and got a 1:7 ratio between the
native image and the assembly, which Accoutns for 20MB (total size of
assemblies) x 7 = 140, to which we can add the system assemblies.

Our questions are:

1) How can we calculate the memory footprint of the assemblies? Are
their any tools to do this? (we tried vadump.exe,however we do nto
fully understand the counters)?

2) Does IL code remain in memory, assuming we do not make any
additional reflection calls after startup? Can this behavior
Be controlled? Does pre-jitting change this behavior?
3) How can we reduce the memory footprint?
- Will linking the assemblies into a single module with multiple
dlls help?
- From reading some articles we understand that the dotnet runtime
pre-allocates large amouts of memory from the unamaged heap if it
notices the apllication is making many managed allocations, and not all
of this memory if later released. Can this behavoir be controlled?

Any ideas, anyone?

assi barak

Jul 21 '05 #1
2 2919
Questions like yours keep coming up in these discussion groups. That
suggests to me that MS should make clearer their memory management practices.
I suggest you search these discussion groups for the following phrases:
WaitForPendingFinalizers
GetTotalMemory
SetProcessWorkingSetSize
You will find interesting reading. The first two are in the GC class, the
third is a win32 api.

I do two things when I want to know what's up with memory. Maybe you should
try them as well, because I have stopped worrying about large footprints
since I know my memory usage is not so bad after all. First, I call
SetProcessWorkingSetSize with -1 and -1 to trim the working set. Then
Diagnostics.Process.GetCurrentProcess.WorkingSet will return a much smaller
number. Second, I do three iterations of garbage collections like this:
Dim i As Integer
Dim l As Long
For i = 1 To 3
GC.Collect()
GC.WaitForPendingFinalizers()
l = GC.GetTotalMemory(True)
Next
At this point, GetTotalMemory returns a low number (not always the lowest,
but such is life).

I only do these things in a development and debugging environment to see if
I have a problem. In production, I think it is better practice to let
MS/Windows/.Net manage memory rather than having me do it.
"assi" wrote:
Hello all

We are developing a large dotnet application, which includes ~ 120
assemblies. (total size of all binaries is ~ 20MB). Our application
also references the following dotnet assemblies: System,System.XML,
System.Windows.Forms, System.Drawing, System.Data,
System.Design. We use dotnet framework 1.1

During initialization, the application scans a directory and loads the
assemblies (using Assembly.LoadFrom). It then scans all types in the
single module in the assembly (using GetModules and Module.GetTypes),
and registers them in application collections by identifying the
properties of each class using reflection.

During the initialization process the memory footprint (both private
bytes and working set) rises to about 220MB, when
#Bytes in all heaps' perfmon counter shows 30MB. This occurs when the
assemlies are scanned, not when they are loaded. The high footprint
causes page faults when the application executes on
some of the target platforms, which has only 256M memory.

To try to account for the 190MB not in the managed heaps, we tried to
estimate the size fo the assemblies in memory when loading. We
pre-jitted the assemblies and got a 1:7 ratio between the
native image and the assembly, which Accoutns for 20MB (total size of
assemblies) x 7 = 140, to which we can add the system assemblies.

Our questions are:

1) How can we calculate the memory footprint of the assemblies? Are
their any tools to do this? (we tried vadump.exe,however we do nto
fully understand the counters)?

2) Does IL code remain in memory, assuming we do not make any
additional reflection calls after startup? Can this behavior
Be controlled? Does pre-jitting change this behavior?
3) How can we reduce the memory footprint?
- Will linking the assemblies into a single module with multiple
dlls help?
- From reading some articles we understand that the dotnet runtime
pre-allocates large amouts of memory from the unamaged heap if it
notices the apllication is making many managed allocations, and not all
of this memory if later released. Can this behavoir be controlled?

Any ideas, anyone?

assi barak

Jul 21 '05 #2

"assi" <as********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello all

We are developing a large dotnet application, which includes ~ 120
assemblies. (total size of all binaries is ~ 20MB). Our application
also references the following dotnet assemblies: System,System.XML,
System.Windows.Forms, System.Drawing, System.Data,
System.Design. We use dotnet framework 1.1

During initialization, the application scans a directory and loads the
assemblies (using Assembly.LoadFrom). It then scans all types in the
single module in the assembly (using GetModules and Module.GetTypes),
and registers them in application collections by identifying the
properties of each class using reflection.

During the initialization process the memory footprint (both private
bytes and working set) rises to about 220MB, when
#Bytes in all heaps' perfmon counter shows 30MB. This occurs when the
assemlies are scanned, not when they are loaded. The high footprint
causes page faults when the application executes on
some of the target platforms, which has only 256M memory.

To try to account for the 190MB not in the managed heaps, we tried to
estimate the size fo the assemblies in memory when loading. We
pre-jitted the assemblies and got a 1:7 ratio between the
native image and the assembly, which Accoutns for 20MB (total size of
assemblies) x 7 = 140, to which we can add the system assemblies.

Our questions are:

1) How can we calculate the memory footprint of the assemblies? Are
their any tools to do this? (we tried vadump.exe,however we do nto
fully understand the counters)?

2) Does IL code remain in memory, assuming we do not make any
additional reflection calls after startup? Can this behavior
Be controlled? Does pre-jitting change this behavior?
3) How can we reduce the memory footprint?
- Will linking the assemblies into a single module with multiple
dlls help?
- From reading some articles we understand that the dotnet runtime
pre-allocates large amouts of memory from the unamaged heap if it
notices the apllication is making many managed allocations, and not all
of this memory if later released. Can this behavoir be controlled?

Any ideas, anyone?

assi barak


Don't know why you are loading all assemblies and scanning them to get the
attributes of all classes.
By doing so, not only do you consume a lot of memory for the DLL's (IL and
metadata) and the administrative data structures needed for the assemblies
loaded, you also consume a fixed amount of 30MB for the "scanned application
collections" before you even have executed a single method of the real
application code - so there is little JITTED code bytes in your private
bytes. Note that the loaded assemblies (your private and the loaded
Framework assemblies), the JITTED code ,the CLR code and Data pages and the
30MB of managed heap is the minimum fixed part of your WS, and this for the
whole duration of your application.

Willy.


Jul 21 '05 #3

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

Similar topics

6
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,...
3
by: Christofer Dutz | last post by:
Hi, First of all sorry for crossposing this question. I just found out that this place fits much more than microsoft.public.dotnet.framework I am playing around a little with C# and the .Net...
1
by: lwickland | last post by:
Summary: System.Net.ScatterGatherBuffers.MemoryChuck allocates inordinately large bytes when sending large post data. The following application consumes inordinate quantities of memory. My code...
8
by: Bob Dufour | last post by:
We got a windows form application that we wrote in VB.Net. Essentially its a manager for a list of persons and their contacts and some other info about the persons. No rocket science but lots of...
2
by: assi | last post by:
Hello all We are developing a large dotnet application, which includes ~ 120 assemblies. (total size of all binaries is ~ 20MB). Our application also references the following dotnet assemblies:...
3
by: nilavya | last post by:
HI, I have an application and trying to figure out the cause for one of the problem. I have a large function in my main class, which in turn calls another function which too has many line of...
11
by: Benny | last post by:
I just wanted to throw the discussion out there on what the best practice people feel is for using large objects in a foreach loop. For example if you are reusing an Image object in a loop like...
3
by: =?Utf-8?B?VG9kZA==?= | last post by:
What is the memory footprint of static methods of a windows app running on a server when the server spins up multiple instances of the application? In my envirionment, we have a Citrix server...
0
by: volt9000 | last post by:
I'm using PdfSharp (an open-source PDF manipulation library) to generate a very large PDF ( 1500+ pages.) My program crashes before reaching the end because of the massive amounts of memory being...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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
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...

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.