Re: Memory Analysis .NET / C#
- From: Arthur M. <ArthurM@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Apr 2005 23:31:01 -0700
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:helge.jensen@xxxxxxx
> sip:helge.jensen@xxxxxxx
> -=> Sebastian cover-music: http://ungdomshus.nu <=-
>
.
- References:
- Memory Analysis .NET / C#
- From: Arthur M.
- Re: Memory Analysis .NET / C#
- From: Helge Jensen
- Memory Analysis .NET / C#
- Prev by Date: Re: is there a way to know if the first reference of the object is data member of class ?
- Next by Date: Re: .NET Framework occurence/spread
- Previous by thread: Re: Memory Analysis .NET / C#
- Next by thread: info VB.Net Pocket PC
- Index(es):
Relevant Pages
|