473,231 Members | 1,527 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,231 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 2345
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.