G
Guest
I noticed some disturbing memory behaviour in the w3wp.exe process running a
web app of mine. I have duplicated it into a simple web service.
Basically, every time I call this web service it adds 3K to the w3wp.exe
process and does not release it. If I call it 30,000 times it adds 100,000 K.
The total bytes allocated according to GC.gettotalmemory stays constant.
The code of the web service follows. I hope I'm missing something simple.
Public Class MemLeak
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function MemoryLeak() As Long
Dim connSQL As New OleDb.OleDbConnection()
Dim cmdSQL As New OleDb.OleDbCommand
Dim strSQL As String, strData As String
Dim i As Integer
Try
connSQL.ConnectionString = "Provider=SQLOLEDB;Data
Source=sql2005;Initial Catalog=myDB;uid=xx;pwd=xx;Encrypt=false;Connect
Timeout=30;Persist Security Info=False;"
cmdSQL.Connection = connSQL
connSQL.Open()
strSQL = "Select max(AppOptions) From Users_AppData where
len(appOptions)>255"
cmdSQL.CommandText = strSQL
' loop 4 times to amplify memory issues
For i = 1 To 4
' The string returned here is 816 char long
strData = cmdSQL.ExecuteScalar.ToString
'strData = Nothing
Next
connSQL.Close()
cmdSQL.Dispose()
connSQL.Dispose()
cmdSQL = Nothing
connSQL = Nothing
Catch ex As Exception
If connSQL.State = ConnectionState.Open Then connSQL.Close()
cmdSQL.Dispose()
connSQL.Dispose()
cmdSQL = Nothing
connSQL = Nothing
End Try
Return GC.GetTotalMemory(True)
End Function
End Class
It is running on Windows Server 2003 v 5.2.3790 SP1 Build 3790, X64
..NET 2.0.50727
Is this a coding issue or an IIS/.NET bug ?
Thanks, Andrew
web app of mine. I have duplicated it into a simple web service.
Basically, every time I call this web service it adds 3K to the w3wp.exe
process and does not release it. If I call it 30,000 times it adds 100,000 K.
The total bytes allocated according to GC.gettotalmemory stays constant.
The code of the web service follows. I hope I'm missing something simple.
Public Class MemLeak
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function MemoryLeak() As Long
Dim connSQL As New OleDb.OleDbConnection()
Dim cmdSQL As New OleDb.OleDbCommand
Dim strSQL As String, strData As String
Dim i As Integer
Try
connSQL.ConnectionString = "Provider=SQLOLEDB;Data
Source=sql2005;Initial Catalog=myDB;uid=xx;pwd=xx;Encrypt=false;Connect
Timeout=30;Persist Security Info=False;"
cmdSQL.Connection = connSQL
connSQL.Open()
strSQL = "Select max(AppOptions) From Users_AppData where
len(appOptions)>255"
cmdSQL.CommandText = strSQL
' loop 4 times to amplify memory issues
For i = 1 To 4
' The string returned here is 816 char long
strData = cmdSQL.ExecuteScalar.ToString
'strData = Nothing
Next
connSQL.Close()
cmdSQL.Dispose()
connSQL.Dispose()
cmdSQL = Nothing
connSQL = Nothing
Catch ex As Exception
If connSQL.State = ConnectionState.Open Then connSQL.Close()
cmdSQL.Dispose()
connSQL.Dispose()
cmdSQL = Nothing
connSQL = Nothing
End Try
Return GC.GetTotalMemory(True)
End Function
End Class
It is running on Windows Server 2003 v 5.2.3790 SP1 Build 3790, X64
..NET 2.0.50727
Is this a coding issue or an IIS/.NET bug ?
Thanks, Andrew