我有一小段代码,我希望GC在某个时候会擦除内存,而不是内存不足。
这是 GC 的正确行为吗?
Private Sub Form1_Load()
Dim WasterWrapper as cMyClass
For MapIndex = 1 To 50
WasterWrapper = New cMyClass
Next
End Sub
这是分配内存的类
Public Class cMyClass
Private mArry(,) As Double
Sub New()
Dim i As Integer
Dim j As Integer
ReDim mArry(5000, 5000)
For i = 0 To 5000
For j = 0 To 5000
mArry(i, j) = Rnd() * 1000
Next
Next
End Sub
Protected Overrides Sub Finalize()
MsgBox("Finalising the wrapper")
MyBase.Finalize()
End Sub
End Class