473,796 Members | 2,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory Analysis .NET / C#

Does anyone know of a way to pin point true memory utilization on a per
object / allocation basis in dot net.

The problem that i'm having is projecting the amount of memory that will be
required by an application.

Obviously there is a component size (i.e. a class that is using 2 32bit
integers will use 8byte) but then there is a question of overhead for .NET
management (i.e. vtables, lookup tables, garbage collector pointer on a per
instance basis etc etc etc... ) Is there a way to determine how much memory
is actually being used by an object (mathematical formula is fine as well).

Going to the same point - how much memory does a delegate take up? In C it
used to be size of an integer....

In the end of the day my problem is this:

If i have 10 million objects loaded in ram, each is at about 40 bytes of
internal value types with 10 delegates within with one function per delegate
(or multicast delegate should I say) how much memory is going to be used when
I fire it up :)

My estimates ranged anywhere from 3 Gb to 9 Gb:) depending on crude methods
I used to evaluate per instance memory utilization
Jul 21 '05 #1
2 2378
Arthur M. wrote:
Obviously there is a component size (i.e. a class that is using 2 32bit
integers will use 8byte) but then there is a question of overhead for .NET
management (i.e. vtables, lookup tables, garbage collector pointer on a per
instance basis etc etc etc... ) Is there a way to determine how much memory
is actually being used by an object (mathematical formula is fine as well).


how about just doing a test: (warning: untested code)

int measurepoints = X;
int distance = Y;
long mem_spent = new long[measurepoints];
Foo[] foos = new Foo[distance*measur epoints];
for ( int i = 0; i < distance*measur epoints; ++i ) {
foos[i] = new Foo(...);
if ( i % distance == 0 ) {
GC.Collect();
GC.WaitForPendi ngFinalizers();
mem_spent[i/distance] = GC.GetTotalMemo ry();
}
}

it will show you how memory-usage relates to the number of objects.

You can even try and run it on your actual code and get a very accurate
estimate that way.

--
Helge Jensen
mailto:he****** ****@slog.dk
sip:he********* *@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Jul 21 '05 #2
Thanks for the suggestion; that is exactly what i ended up doing... in truth
though I'm looking for a well defined formula that says that a 'pointer' to
an object takes up (guessing) 16 bytes 4 for real pointer 4 for garbage
collection 4 for a lookup table and 4 for something else; that way I would
not need to do a guess work ...

"Helge Jensen" wrote:
Arthur M. wrote:
Obviously there is a component size (i.e. a class that is using 2 32bit
integers will use 8byte) but then there is a question of overhead for .NET
management (i.e. vtables, lookup tables, garbage collector pointer on a per
instance basis etc etc etc... ) Is there a way to determine how much memory
is actually being used by an object (mathematical formula is fine as well).


how about just doing a test: (warning: untested code)

int measurepoints = X;
int distance = Y;
long mem_spent = new long[measurepoints];
Foo[] foos = new Foo[distance*measur epoints];
for ( int i = 0; i < distance*measur epoints; ++i ) {
foos[i] = new Foo(...);
if ( i % distance == 0 ) {
GC.Collect();
GC.WaitForPendi ngFinalizers();
mem_spent[i/distance] = GC.GetTotalMemo ry();
}
}

it will show you how memory-usage relates to the number of objects.

You can even try and run it on your actual code and get a very accurate
estimate that way.

--
Helge Jensen
mailto:he****** ****@slog.dk
sip:he********* *@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-

Jul 21 '05 #3

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

Similar topics

0
1344
by: Josh Buedel | last post by:
I've been evaluating PurifyPlus and DevPartner for their memory analysis features when doing C# development. For the most part I find them to be nearly identical in functionality. PurifyPlus gives a memory graph showing the entire application lifetime, whereas DevPartner only shows the last minute or so. But DevPartner was easier to get up and running with, and it has a friendlier look and feel, for whatever that's worth. Does...
1
5896
by: Ben | last post by:
I have written a procedure which calls the CORREL function of Excel to run correlation analysis on two arrays, then populate a table with the resulting correlation coefficient. This process loops through several records and recordsets. The procedure works well for awhile (sometimes upwards of 10,000 times!), but then mysteriously begins populating "0" as the correlation coefficient (even though I know this to be inaccurate). Sometimes,...
18
3714
by: jacob navia | last post by:
In C, we have read-only memory (const), read/write memory (normal data), and write only memory. Let's look at the third one in more detail. Write only memory is a piece of RAM that can only be written to, since its contents are undefined. The program is allocating a new piece of data, and the previous contents aren't relevant. This memory
16
2392
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. Example: After about 5 hours with a concurrent user base of about 150 users the application raises the aspnet_wp memory usage by almost 500MB. If our server guys modify the web.config this data is released and the workerprocess goes back to a...
4
3432
by: Hermann Maier | last post by:
hi, i need to find out the memory usage of a specific function that i use in my program. this function does some recursive calculations and i want my program to display the amount of memory the function used to calculate a specific value. thx
1
2318
by: Charlotte | last post by:
Hello, We are doing a stability test on our application to prepare for Microsoft SQL Server 2000 certification, and we found a memory leak, but we cannot find its source and fix it. We use an ASP page written in JScript that connects to Analysis Services 2000 using ADOMD and retrieves data from it (this is a very simplified version of our real application that we created just to test the memory leak), see the code below.
5
1106
by: Frank Rizzo | last post by:
Hello, I have a very frustrating issue I've been working on. I have a routine that does the following: 1. Load a large (declared local to the function) DataSet from the database. It contains 5 tables. 2. Load the database into a fairly complicated object model. 3. I dispose of the Dataset. Before loading the DataSet the MemUsage column in Task Manager shows 44 MB. After loading the database the MemUsage stands at 59 MB. Thus I
10
2313
by: deciacco | last post by:
I'm writing a command line utility to move some files. I'm dealing with thousands of files and I was wondering if anyone had any suggestions. This is what I have currently: $arrayVirtualFile = array( 'filename'=>'filename', 'basename'=>'filename.ext', 'extension'=>'ext', 'size'=>0,
5
12650
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
22
9365
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a memory leak someplace. I can not detect the memory leak by running several reports by hand, but when I run tha app as a servrice and process few hundred reports there is significant memory leak. The application can consume over 1GB of memory where it...
0
9679
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
9527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
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
10223
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...
0
9050
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
7546
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.