Possible memory leak ?

G

Guest

When I use the following code in VB.NET :

Public Function test() As String
Try
Dim da1 As OdbcDataAdapter
Dim i As Int32
Dim tfem As DataTable
For i = 0 To 1000
da1 = New OdbcDataAdapter("select * from TABLE1 where
TABLE1.ID= '16'", "DSN=DSNTEST;UID=UIDTEST;PWD=PWDTEST;")
tfem = New DataTable
tfem.TableName = "TABLE1"
da1.Fill(tfem)
tfem.Dispose()
tfem = Nothing
da1.Dispose()
da1 = Nothing
Next
Catch lerr As Exception
Return lerr.Message
End Try
Return "Ok"
End Function

or this one :

Public Function test1() As String
Try
Dim da1 As OdbcDataAdapter
Dim i As Int32
Dim tfem As DataTable
da1 = New OdbcDataAdapter("select * from TABLE1 where TABLE1.ID=
'16'", "DSN=DSNTEST;UID=UIDTEST;PWD=PWDTEST;")
da1.SelectCommand.CommandTimeout = 0
tfem = New DataTable
tfem.TableName = "TABLE1"
For i = 0 To 1000
da1.Fill(tfem)
tfem.Rows.Clear()
tfem.Reset()
Next
tfem.Dispose()
tfem = Nothing
da1.Dispose()
da1 = Nothing

Catch lerr As Exception
Return lerr.Message
End Try
Return "Ok"
End Function

the memory used by my webservice and/or executable never stop growing until
the webservice and/or executable stop responding...The only solution is to
kill aspnet_wp.exe and/or executable to get back the memory used.

Any suggestions ?
 
C

Cor Ligthert

Emmanuel,

We have seen this behaviour before in my idea in the newsgroup General by a
problem that Marina had sent.

As long as it was inside a methodloop the GC was hardly called. A show did
help and explicitly calling the GC as well. (As far as I remember it me was
that creating not showing controls).

I thought that we did not try application.doEvents then, maybe you can try
that yourself because you cannot use the show here

In my opinion does all that dispose and setting to nothing not help you at
all.

Just some idea's

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top