Releasing memory (continuation)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: nisant (nisant_at_discussions.microsoft.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 02:33:02 -0700

I "refresh" the thread
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?&guid=&sloc=en-us&dg=microsoft.public.vb.general.discussion&p=1&tid=9e29a210-89db-40ef-80b7-77f42b00681a

because many solutions have been proposed and I wanted to verify and give
results to the ng.

I verified objects collection vs objects array (no doubt about the fact that
UDTs array would be the fastest).

That's what appened working with 100000 instances:

OBJECTS COLLECTION
--------
Dim coll As New Collection

    For i = 0 To 100000
        coll.Add New myObject, CStr(i)
    Next i
Allocation: 8 seconds

    For i = 0 To 100000
        coll.Remove CStr(i)
    Next i
Release: 35 seconds

    For i = 0 To 100000
        coll.Remove 1
    Next i
Release: 33 seconds

    For i = 100000 To 0 Step -1
        coll.Remove i
    Next i
Killed after 2 minutes, only about 10000 objects released

    For i = 100000 To 0 Step -1
        coll.Remove CStr(i)
    Next i
Release: 34 seconds

    Set coll = Nothing
Release: 32 seconds

OBJECTS ARRAY
-------
Dim arr(100000) As myObject

    For i = 0 To UBound(arr, 1)
        Set arr(i) = New myObject
    Next i
Allocation: 2 seconds

    For i = 0 To UBound(arr, 1)
        Set arr(i) = Nothing
    Next i
Release: 17 seconds

    For i = UBound(arr, 1) To 0 Step -1
        Set arr(i) = Nothing
    Next i
Release: 17 seconds

I also tried a dynamic array released by Redim arr(0); same elapsed as above:
Allocation: 2 seconds
Release: 17 seconds

COMMENTS:

a) Arrays are very faster than Collections

b) Rank
    1 - Set coll = Nothing
    2 - Removing 1st ordinal item
    3 - Removing in reversed key order
    4 - Removing in key order
    5 - Removing in reversed ordinal order (geologic time)

c) Release time in collection test seems to be spent 1/2 navigating thru the
collection, 1/2 releasing memory. Total time about 34 seconds, only 17
seconds the memory release time, as derived from array test (where non
navigation occurs).

d) It seems that nothing can speed up memory release of instances (arrays
perform better because there is no collection structure to navigate thru, but
memory release time remains the same).

So one question remains I can't imagine the answer:

What does system do to release the process memory instantly when I kill the
process?

Many many many thanks for an answer.

PS
About Scripting.Dictionary:
I hope I will try soon

About SQL Server:
My in-memory DB is loaded from a disk database (MS Access).
I choose an in-memory structure to process data because of speed needs

Tank you nevertheless.



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.language)
  • Re: OOP and C++ and C (was Re: Dennis Ritchie -- An Appreciation)
    ... different layout in memory. ... memory is one large array like structure. ... That's the fundamental abstraction that our hardware attempts to ...
    (comp.lang.c)
  • 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)