Is there a way to control the amount of Virtual Memory that a VB.net program uses? Is there a line of code that will release a program's VM?
Example: We have a web spider that works very well for about 60 to 120 minutes but will ALWAYS end with a 'System.StackOverFlowException in System.dll' error. The Application log references kernel32.dll for the same error. In Visual Studio, the error dialog box is entitled 'StackOverFlowException was unhandled' and points to this line of code...
Dim response As HttpWebResponse = request.GetResponse()
However the code is in a Try/Catch block with a Throw statement.
(see full code block below)
As a beginner, I suspect Virtual Memory may be the problem because as the program runs, VM slowly increases until it hits 200MB or more and then the error occurs. This happens every single time and always within 1 to 2 hours of starting the program.
Any suggestions?
'code block in question
Public Function GetFile(ByVal urlValue As String) As String
Dim allText As String = ""
Try
Dim request As HttpWebRequest = WebRequest.Create(urlValue)
request.Timeout = 5000
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
allText = reader.ReadToEnd
request = Nothing
response.Close()
response = Nothing
reader.Close()
reader = Nothing
Catch ex As Exception
Throw ex
End Try
Return allText
End Function
Example: We have a web spider that works very well for about 60 to 120 minutes but will ALWAYS end with a 'System.StackOverFlowException in System.dll' error. The Application log references kernel32.dll for the same error. In Visual Studio, the error dialog box is entitled 'StackOverFlowException was unhandled' and points to this line of code...
Dim response As HttpWebResponse = request.GetResponse()
However the code is in a Try/Catch block with a Throw statement.
(see full code block below)
As a beginner, I suspect Virtual Memory may be the problem because as the program runs, VM slowly increases until it hits 200MB or more and then the error occurs. This happens every single time and always within 1 to 2 hours of starting the program.
Any suggestions?
'code block in question
Public Function GetFile(ByVal urlValue As String) As String
Dim allText As String = ""
Try
Dim request As HttpWebRequest = WebRequest.Create(urlValue)
request.Timeout = 5000
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
allText = reader.ReadToEnd
request = Nothing
response.Close()
response = Nothing
reader.Close()
reader = Nothing
Catch ex As Exception
Throw ex
End Try
Return allText
End Function