Re: redim'ing an array smaller

From: J French (erewhon_at_nowhere.com)
Date: 07/16/04


Date: Fri, 16 Jul 2004 17:41:42 +0000 (UTC)

On Fri, 16 Jul 2004 09:16:14 -0500, "Larry Serflaten"
<serflaten@usinternet.com> wrote:

>
>"J French" <erewhon@nowhere.com> wrote
>
>
>> So there is no zeroing of memory, also I suspect that memory
>> de-allocation is faster than allocation, and I've just seen that if
>> one increases the size of the Array it does not move
>
>
>Did you increase it large enough?
>
>IIRC the system allocates memory in 4K chunks, so if your
>array fit inside that size, it may not have moved. But try to
>use more than that, and it may well be moved as needed.
>
>I have to agree with the ReDim Preserve for going smaller.
>Without testing it, it sure sounds like it should be faster than
>not using Preserve.

That makes sense, I'll test a huge array (well over 4k), then RedDim
it down, the ReDim it back up again

I wonder whether VB does 'lazy' heap garbage collection



Relevant Pages

  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: High Memory Consumption of Classes and Arrays
    ... Only the array itself has overhead. ... memory as a reference type. ... > least consume 40 bytes of memory. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.mfc)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.language)
  • Re: not enough storage... error using GetRows
    ... > array only contained ~150,000 rows. ... It took 19 minutes for GetRows to return (db ... and the prog had consumed 200MB of memory. ... The first one allocates some 180MB, the next two only allocate about 47MB ...
    (microsoft.public.vb.database.ado)