469,946 Members | 2,120 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Possible memory leak ?

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 never stop growing until the webservice
stop responding...The only solution is to kill aspnet_wp.exe to get back the
memory used.

Any suggestions ?
Nov 23 '05 #1
3 4311
Hello Emmanuel,
Thats not a memory leak. Thats just the dataset consuming memory :).
When the GC comes around to pick it up the memory should be freed.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
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 never stop growing until the
webservice stop responding...The only solution is to kill
aspnet_wp.exe to get back the memory used.

Any suggestions ?


Nov 23 '05 #2
Dilip Krishnan wrote:
Hello Emmanuel,
Thats not a memory leak. Thats just the dataset consuming memory :).
When the GC comes around to pick it up the memory should be freed.
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
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 never stop growing until the
webservice stop responding...The only solution is to kill
aspnet_wp.exe to get back the memory used.

Any suggestions ?


i can`t even inmagine how to make a memory leak with VB.net as the GC
should take care of it ( then it would be a bug in the framework )

Nov 23 '05 #3
Hello M.Posseth,
It is possible :) if you write code that makes you're object appear referenced
all the time.. sure the GC would never collect it and it will remain in memory
forever and ever :)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Dilip Krishnan wrote:
Hello Emmanuel,
Thats not a memory leak. Thats just the dataset consuming memory :).
When the GC comes around to pick it up the memory should be freed.
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
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 never stop growing until the
webservice stop responding...The only solution is to kill
aspnet_wp.exe to get back the memory used.
Any suggestions ?

i can`t even inmagine how to make a memory leak with VB.net as the GC
should take care of it ( then it would be a bug in the framework )


Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Roman Mashak | last post: by
8 posts views Thread by ranjeet.gupta | last post: by
17 posts views Thread by Josť Joye | last post: by
4 posts views Thread by Don Nell | last post: by
20 posts views Thread by jeevankodali | last post: by
3 posts views Thread by Jim Land | last post: by
7 posts views Thread by Ragnar Agustsson | last post: by
22 posts views Thread by Peter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.