Re: Framework 2.0 array redim unsatisfactory performance



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
> |
> |
>
>


.



Relevant Pages

  • Re: Framework 2.0 array redim unsatisfactory performance
    ... implementation details of Redim, Redim Preserve, and List. ... significantly higher object allocated overhead then List. ... ReDim simply allocates a new ... but I do not even attempt to test its memory ...
    (microsoft.public.dotnet.languages.vb)
  • Re: CE6.0 Driver Pointer Marshalling - passing pointers out only?
    ... This is an array of pointers to buffers that get set up ... the driver allocates the buffers (via an internal allocation ... routine from its own block of reserved memory). ... So I can map ...
    (microsoft.public.windowsce.platbuilder)
  • Re: CE6.0 Driver Pointer Marshalling - passing pointers out only?
    ... I've got a pretty complex driver I'm porting up at the moment ... This is an array of pointers to buffers that get set up ... the driver allocates the buffers (via an internal allocation ... routine from its own block of reserved memory). ...
    (microsoft.public.windowsce.platbuilder)
  • Re : Re : memory allocation and freeing memory
    ... This means that the caller ... >> never frees memory, and the callee always frees all its ... then the caller allocates it and pass it ... > void ExprDestroy(Expr *expr) { ...
    (comp.lang.c)
  • Re: simplest dynamic memory manager / allocator
    ... You might find that 4tH doesn't reserve much memory for dynamic ... memory is allocated at the heap, ... 768 allocates 64 bytes. ... Every fragment is represented by a cell in the HAT. ...
    (comp.lang.forth)