Re: Framework 2.0 array redim unsatisfactory performance
- From: "Tom Jastrzebski" <tom@xxxxxxx>
- Date: Fri, 12 Aug 2005 00:57:55 GMT
Jay,
I am aware of GC issues. However, for the purpose of simple collection test
it simply does not matter, since no object is released for GC, and no memory
deallocated until the application exits. Of course, that is not true for the
"array redim" test, but I do not even attempt to test its memory efficiency.
There also might be an exception for Hashtable with too small initial
capacity, but I would not bet on this.
But, if I you would like to continue, I am wondering what memory overhead
your tests show. Let's say List(Of Integer) with one million elements.
My tests show that static arrays are surprisingly efficient, virtually no
overhead. Dynamic structures, however, is the whole different story.
Cheers,
Tomasz
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@xxxxxxx> wrote in message
news:ODzLi1hnFHA.2484@xxxxxxxxxxxxxxxxxxxxxxx
> Tom,
> | Process.GetCurrentProcess().WorkingSet64
> WorkingSet64 is the Working Set or total amount of physical memory in use,
> this is by no means the amount of memory the GC has allocated. In other
> words it includes objects that have not yet been garbage collected, plus
> it
> includes the space for objects that were previously allocated but have
> already been collected.
>
> As I stated, the GC over allocates physical memory as needed & will only
> return it when the OS requests it as another app is asking for more
> memory... In other words the Working Set includes both allocated memory &
> free memory. You need to use the .NET performance counters or CLR Profiler
> to see how much memory is currently allocated.
>
> | What I am looking for is dynamic data structure which has the least
> memory
> | overhead.
> That would be List(Of T) with the "capacity" constructor set to the
> expected
> number of elements. For example if you know there are going to be 50 to 75
> elements in the list, but no more then 100. I would pass 50 or 75 to the
> constructor. With 50, there would be at most a single reallocation.
>
> If your not sure what the limit is going to be, but once the list is
> filled
> its "constant", the I would recommend using List(Of T).TrimExcess when I
> finished filling the list.
>
> http://msdn2.microsoft.com/library/ms132207(en-us,vs.80).aspx
>
> Hope this helps
> Jay
>
> "Tom Jastrzebski" <tom@xxxxxxx> wrote in message
> news:qNxKe.68$UA1.27@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> | Jay,
> |
> | I just noticed something I thought was interesting and decided to write
> | about it, thinking that someone migrating from VB 6.0 may experience
> this
> | issue, regardless of what the root cause is and whether these
> environments
> | should be compared or not.
> |
> | As I said, the only reason why I tried "array redim" was because I was
> | hoping to be nicely surprised - and I was not.
> |
> | What I am looking for is dynamic data structure which has the least
> memory
> | overhead.
> | It seems like at some point I will have to develop my own. But that is
> OK,
> | it by no means diminish the value of .Net Framework.
> |
> | To check process memory utilization I use:
> | Process.GetCurrentProcess().WorkingSet64
> |
> | Peace,
> | Tomasz
> |
> |
>
>
.
- Follow-Ups:
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Jay B. Harlow [MVP - Outlook]
- Re: Framework 2.0 array redim unsatisfactory performance
- References:
- Framework 2.0 array redim unsatisfactory performance
- From: Tom Jastrzebski
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Jay B. Harlow [MVP - Outlook]
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Tom Jastrzebski
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Jay B. Harlow [MVP - Outlook]
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Tom Jastrzebski
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Jay B. Harlow [MVP - Outlook]
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Tom Jastrzebski
- Re: Framework 2.0 array redim unsatisfactory performance
- From: Jay B. Harlow [MVP - Outlook]
- Framework 2.0 array redim unsatisfactory performance
- Prev by Date: Re: Merge a string doesn't work
- Next by Date: Re: String.Format used to make columns
- Previous by thread: Re: Framework 2.0 array redim unsatisfactory performance
- Next by thread: Re: Framework 2.0 array redim unsatisfactory performance
- Index(es):
Relevant Pages
|