Hi Steve,
GC only collects when it _needs_ to. Given todays RAM capacities, 24MB (I
assume this was the working set?) doesn't have to force a GC collection,
unless there are a lot of other memore-intensive applications yearning for
more.
"Steve Spears via .NET 247" <anonymous@dotnet247.com> schrieb im Newsbeitrag
news:%23aTOsLbKFHA.1176@TK2MSFTNGP15.phx.gbl...
Hello, I need some help finding out what I am missing here. I have a
connection to a SQL server, which I hope I am closing correctly, leaking
memory. The function is called from a Timer and it is leaking 4 to 8k per
cycle. I thought it was the GC not cleaning up but after a 24 hour period
the app was at 24MB of memory...
Sub ProcessHB(ByVal strServer As String, ByVal RobotNumber As Integer)
Try
Dim ComputerName As String
ComputerName = System.Net.Dns.GetHostName
Dim con As New SqlConnection("Data Source=" & strServer & ";" &
_
"Initial Catalog=MyDBName;Integrated Security=SSPI")
con.Open()
Dim cmd As SqlCommand = New SqlCommand("INSERT SQL UPDATE
STATEMENT", con)
cmd.ExecuteNonQuery()
cmd.Dispose()
cmd = Nothing
con.Close()
con.Dispose()
con = Nothing
strServer = Nothing
RobotNumber = Nothing
GC.Collect()
Catch ex As System.InvalidOperationException
Console.WriteLine(ex.Message)
Catch ex As System.Data.SqlClient.SqlException
Console.WriteLine(ex.Message)
End Try
End Sub
--------------------------------
From: Steve Spears
-----------------------
Posted by a user from .NET 247 (
http://www.dotnet247.com/)
<Id>LEUI7WhXsUibbKLjJO+sJw==</Id>