Connecting Tech Pros Worldwide Forums | Help | Site Map

Possible memory leak ?

Emmanuel Gehin
Guest
 
Posts: n/a
#1: Nov 23 '05
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 ?

Dilip Krishnan
Guest
 
Posts: n/a
#2: Nov 23 '05

re: Possible memory leak ?


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
[color=blue]
> 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 ?
>[/color]



M.Posseth
Guest
 
Posts: n/a
#3: Nov 23 '05

re: Possible memory leak ?


Dilip Krishnan wrote:[color=blue]
> 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
>[color=green]
>> 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 ?
>>[/color]
>
>
>[/color]
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 )

Dilip Krishnan
Guest
 
Posts: n/a
#4: Nov 23 '05

re: Possible memory leak ?


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
[color=blue]
> Dilip Krishnan wrote:
>[color=green]
>> 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[color=darkred]
>>> 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 ?
>>>[/color][/color]
> 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 )
>[/color]



Closed Thread