Hi,
I'm encountering a strange phenomenon whereby a DataSet object is not
releasing its memory when it's being disposed and/or set to Nothing.
It is part of a Windows service written in VB.NET which fetches data out of
a mySQL database, interrogates each row individually and takes various
actions accordingly. It can fetch upwards of 300,000 rows, each of which
vary between 1k and 2k in size, making the resulting DataSet object almost
500Mb in size. This in itself is not much of a problem, except that when the
service has finished working with the DataSet, it does not release the
memory it has been using.
I'm using it in what appears to me at least to be a fairly standard way
(code at the end of this post).
What do I have to do to free up the memory allocated to the DataSet object?
I've even tried running System.GC.Colle ct(), though that expectedly made no
difference.
Any assistance gratefully received.
Mark Rae
Option Explicit On
Option Strict On
Imports CoreLab.MySql
Imports System.Collecti ons
Imports System.Data
Imports System.Xml
Public Function Import(pstrMySQ LConnectString As String, pstrSQL As String)
As Boolean
Dim objMySQL As New CMySQLCoreLab(p strMySQLConnect String)
Dim objMySQLDS As DataSet
objMySQLDS = objMySQL.GetDat aSet(pstrSQL)
For Each objRow As DataRow in objMySQLDS.Tabl es(0).Rows
'
' do the processing
'
Next
objMySQLDS.Disp ose
objMySQLDS = Nothing
objMySQL.Dispos e
objMySQL = Nothing
End Function
I'm encountering a strange phenomenon whereby a DataSet object is not
releasing its memory when it's being disposed and/or set to Nothing.
It is part of a Windows service written in VB.NET which fetches data out of
a mySQL database, interrogates each row individually and takes various
actions accordingly. It can fetch upwards of 300,000 rows, each of which
vary between 1k and 2k in size, making the resulting DataSet object almost
500Mb in size. This in itself is not much of a problem, except that when the
service has finished working with the DataSet, it does not release the
memory it has been using.
I'm using it in what appears to me at least to be a fairly standard way
(code at the end of this post).
What do I have to do to free up the memory allocated to the DataSet object?
I've even tried running System.GC.Colle ct(), though that expectedly made no
difference.
Any assistance gratefully received.
Mark Rae
Option Explicit On
Option Strict On
Imports CoreLab.MySql
Imports System.Collecti ons
Imports System.Data
Imports System.Xml
Public Function Import(pstrMySQ LConnectString As String, pstrSQL As String)
As Boolean
Dim objMySQL As New CMySQLCoreLab(p strMySQLConnect String)
Dim objMySQLDS As DataSet
objMySQLDS = objMySQL.GetDat aSet(pstrSQL)
For Each objRow As DataRow in objMySQLDS.Tabl es(0).Rows
'
' do the processing
'
Next
objMySQLDS.Disp ose
objMySQLDS = Nothing
objMySQL.Dispos e
objMySQL = Nothing
End Function
Comment