Array/Variable Disposal

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I have a program that uses multiple arrays and the memory useage is
huge. After a proceedure ends is there a good way to shrink down an
array's size. The same for variables.
 
Peter said:
I have a program that uses multiple arrays and the memory useage
is huge. After a proceedure ends is there a good way to shrink down
an array's size. The same for variables.

The array is only stored in a local variable? Then the variable runs out of
scope, which means the reference to the array is deleted and the array can
be collected by the garbage collector. It destroys the object and frees
memory if it's time:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconautomaticmemorymanagement.asp?frame=true


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
* (e-mail address removed) (Peter) scripsit:
I have a program that uses multiple arrays and the memory useage is
huge. After a proceedure ends is there a good way to shrink down an
array's size. The same for variables.

If the array is declared inside the procedure, like:

\\\
Public Sub Foo()
Dim astr() As String
...
End Sub
///

.... it's ready to be destroyed by the Garbage Collector when the
procedure is left. Notice that there is no deterministic cleanup in
..NET, so task manager may show wrong results of what amount of memory is
really used by your app's "living" objects.
 
Back
Top