|
Prev: inputbox
Next: FAXCOMLIB send error
From: Mark Rae on 14 Feb 2005 15:20 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
From: Chad Z. Hower aka Kudzu on 14 Feb 2005 17:38 "Mark Rae" <mark(a)mark-N-O-S-P-A-M-rae.co.uk> wrote in news:ujdOYKtEFHA.2572(a)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/
From: Mark Rae on 14 Feb 2005 18:53 "Chad Z. Hower aka Kudzu" <cpub(a)hower.org> wrote in message news:Xns95FDB3628FD57cpub(a)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?
From: Chad Z. Hower aka Kudzu on 14 Feb 2005 20:05 "Mark Rae" <mark(a)mark-N-O-S-P-A-M-rae.co.uk> wrote in news:evkShBvEFHA.3032(a)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/
From: Cor Ligthert on 15 Feb 2005 04:15
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 |