473,385 Members | 2,274 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,385 software developers and data experts.

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 2500

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.