By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,199 Members | 1,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,199 IT Pros & Developers. It's quick & easy.

DataSet object not releasing memory

P: n/a
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.Collect(), though that expectedly made no
difference.

Any assistance gratefully received.

Mark Rae
Option Explicit On
Option Strict On

Imports CoreLab.MySql
Imports System.Collections
Imports System.Data
Imports System.Xml

Public Function Import(pstrMySQLConnectString As String, pstrSQL As String)
As Boolean

Dim objMySQL As New CMySQLCoreLab(pstrMySQLConnectString)
Dim objMySQLDS As DataSet

objMySQLDS = objMySQL.GetDataSet(pstrSQL)

For Each objRow As DataRow in objMySQLDS.Tables(0).Rows
'
' do the processing
'
Next

objMySQLDS.Dispose
objMySQLDS = Nothing
objMySQL.Dispose
objMySQL = Nothing

End Function
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in
news:uj**************@tk2msftngp13.phx.gbl:
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.


How are you measuring this fact? Dispose does not actually free the memory,
thats up to the GC.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Nov 21 '05 #2

P: n/a
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
How are you measuring this fact?
By looking at Task Manager.
Dispose does not actually free the memory,


According to the MSDN docs, the Dispose method "releases all resources used
by the System.ComponentModel.Component" - are you saying that doesn't
include the memory that the component has been allocated?
Nov 21 '05 #3

P: n/a
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in
news:ev**************@TK2MSFTNGP12.phx.gbl:
How are you measuring this fact?


By looking at Task Manager.


Never use TM for memory measurement, ESPECIALLY with .NET applications.
Dispose does not actually free the memory,


According to the MSDN docs, the Dispose method "releases all resources
used by the System.ComponentModel.Component" - are you saying that
doesn't include the memory that the component has been allocated?


Correct. You should read up on the GC in .NET. In .NET release <> Free up
memory.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 21 '05 #4

P: n/a
Mark,

There should not be any reason to dispose a dataset, it cost only (very few)
time.

When you want to clear it, have a look at
dataset.clear or dataset.reset

Forcing the Garbage Collector will cost time at moments that it is
inefficient.

I hope this helps?

Cor
Nov 21 '05 #5

P: n/a
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...

Cor,

Thanks for the reply - some practical advice!
There should not be any reason to dispose a dataset, it cost only (very
few) time.

When you want to clear it, have a look at
dataset.clear or dataset.reset
OK - I'll certainly have a look at that.
Forcing the Garbage Collector will cost time at moments that it is
inefficient.


Yes - I don't like to force a System.GC.Collect()...

Mark
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.