473,471 Members | 4,616 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

memory 'leak' in dataTable/dataRow

I am encountering the following strange problem which causes the application
to use more memory then it should.
I have 5 database tables. lets pretend I want to load each one of them into
a dataTable. then, run over all the rows of the dataTable and for each cell
in the dataRow concatenate a string (the value in the cell is a string to
begin with).
I expect the memory to go up every time I load a dataTable, even go up when
I modify the rows, but I expect it to
go down when the loop ends and then go up again when the new dataTable is
loaded. however, the memory simply adds-up... each dataTable just adds to
the memory and it is as if the last dataTable is not releases. more
precisely, I found the problem is not the dataTable but the strings. it
seems the string (new, old) that I modify are not cleared from the memory.
here is a sample of what I do and causes the memory 'leak'. below this
sample I also specify what I did that DOES work (seems to have no memory
build up), however, that solution is not acceptable:

'------------------------
Dim tables() As String = {"5Tbl", "4Tbl", "3Tbl", "2Tbl", "1Tbl"}
For Each table As String In tables
Console.WriteLine("loading table:" + table)
'loads the table into memory
Dim dt As DataTable
Dim sqlIns As String = "SELECT * FROM " + table
dt = m_dbMaster.getDataTable(sqlIns)

'added this just to make sure
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
System.GC.Collect()

System.Threading.Thread.Sleep(5000)
Console.WriteLine("working table:" + table)
Dim dr As DataRow
For Each dr In dt.Rows
dr("w1") = CStr(dr.Item("w1"))
dr("w2") = CStr(dr.Item("w2"))
dr("w3") = CStr(dr.Item("w3"))
dr("w4") = CStr(dr.Item("w4"))
Next
System.Threading.Thread.Sleep(5000)
'------------------------

OK, so before you tell me it is probably the getDataTable function that is
not working well hear this:
if I change the lines
dr("w1") = CStr(dr.Item("w1")) to
dr("w1") = "xxxxxxxxxxxxxxxxxxxx" (that is, I am replacing the value in the
cell with a literal instead of a string generated from its original value)
the EVERYTHING IS JUST FINE!!! memory goes up and down as it is supposed to.
anyone has any idea what is going on?

regards and thanks in advance.
Jul 21 '05 #1
0 2508

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Newbie | last post by:
Im getting an exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
0
by: dudi | last post by:
I am encountering the following strange problem which causes the application to use more memory then it should. I have 5 database tables. lets pretend I want to load each one of them into a...
3
by: Emmanuel Gehin | last post by:
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...
10
by: mark | last post by:
I have a simple windows application that has a function to read a csv file and enter the values into an array A as double(,). Also, an instance of form 2 (which has a DataGrid) is created and the...
2
by: J. Clay | last post by:
Developing in VS 2005 I have WinForm app that utilizes several class objects and is databound to a couple of objects. One of the classes uses a timer to query an in memory database every second...
1
by: Dean Slindee | last post by:
I have noticed that doing a datatable.reset() wipes out an "independently" declared datarow copied from a single datatable row. What is curious is that if a dataset is substituted for the...
6
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a...
11
by: Aleks Kleyn | last post by:
I wrote application on asp.net 2.0 using dataset. One dataset I put in session collection and other (which is small and common for other users) I put in application. I expected that it will get...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.