473,387 Members | 1,882 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.

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 2350
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*measurepoints];
for ( int i = 0; i < distance*measurepoints; ++i ) {
foos[i] = new Foo(...);
if ( i % distance == 0 ) {
GC.Collect();
GC.WaitForPendingFinalizers();
mem_spent[i/distance] = GC.GetTotalMemory();
}
}

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*measurepoints];
for ( int i = 0; i < distance*measurepoints; ++i ) {
foos[i] = new Foo(...);
if ( i % distance == 0 ) {
GC.Collect();
GC.WaitForPendingFinalizers();
mem_spent[i/distance] = GC.GetTotalMemory();
}
}

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
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...
1
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...
18
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...
16
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. ...
4
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...
1
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...
5
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...
10
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 =...
5
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
22
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...
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: 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: 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
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: 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
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
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,...
0
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...

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.