473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

DataSet object not releasing memory

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
5 9174
"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
"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
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: music4 | last post by:
Greeting, My platform is Solaris 2.8. My question is that if there is a simple way to put a class object in share memory, so that multiple process can use this object. Thanks in advance! Evan
35
by: MuZZy | last post by:
Hi All, I got a issue here and hope someone can help me: Let's consider this code: // =================== CODE START ================================= using System; using System.Data; ...
3
by: greg.merideth | last post by:
There's a utility application I have that generates Excel files for the end users that 99% of the time works just fine. The problem I've encountered is when placing a lot of data (and by a lot I...
5
by: david.kao | last post by:
Hi All: I am creating a COM+ Pool object in C#. I set up the following attributes: JIT (true),Pool size; and at the end of each public method I called ContextUtil.DeactivateOnReturn=true to set...
2
by: Lawrence Chang | last post by:
Hi My friends, Can I save dataset object to an application variable? I want all the customer use this dataset. and diffrent customer create diffrent dataview object from this dataset, so it...
3
by: GBR | last post by:
I have a collection object inherited from collection base that is used to carry my object entities from server to client through a web service. I want to add a dataset to this collection object and...
6
by: Pablo | last post by:
Hello, I am writing a windows application using C++ and BorlandBuilder 6 compiler. It is an event driven program and I need to create objects of some classes written by me. One of the classes...
2
by: Ivor Somerset | last post by:
Hello, In my ASP code I sometimes write functions that return an object (generally an XML node). Such a function is invoked this way: Set Object1 = MyFunction(SomeValue) And at the end of...
7
by: Piotrekk | last post by:
Hi I am using INCA RTX library which i've added to my project resources. Then i created an object i need to release it manually. I have found example in MSND - how to release com object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.