string object not being release
Posted on 2010-11-29
This is probably a stupid question but how can I release the memory without calling gc.collect()
The code bellow uses 800MB of memory when we click on button1, button2 doesn't seem to release anything, event after 5 minutes, (in release compilation)
Public Class Form1
Dim l() As String
Dim s = 10000
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
l(0) = "fkdnm"
For i = 1 To s - 1
l(i) = l(i - 1) & "fkdnmvgd"
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i = 0 To s - 1
l(i) = ""
l(i) = Nothing
l = Nothing
Yes, I know I should use stringbuilder