473,769 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ 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.WriteLi ne("loading table:" + table)
'loads the table into memory
Dim dt As DataTable
Dim sqlIns As String = "SELECT * FROM " + table
dt = m_dbMaster.getD ataTable(sqlIns )

'added this just to make sure
System.GC.Colle ct()
System.GC.WaitF orPendingFinali zers()
System.GC.Colle ct()

System.Threadin g.Thread.Sleep( 5000)
Console.WriteLi ne("working table:" + table)
Dim dr As DataRow
For Each dr In dt.Rows
dr("w1") = CStr(dr.Item("w 1"))
dr("w2") = CStr(dr.Item("w 2"))
dr("w3") = CStr(dr.Item("w 3"))
dr("w4") = CStr(dr.Item("w 4"))
Next
System.Threadin g.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("w 1")) to
dr("w1") = "xxxxxxxxxxxxxx xxxxxx" (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 2533

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

Similar topics

2
11151
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 System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at System.Data.Common.Int32Storage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <BILLABLE...
0
3169
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 datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
0
298
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 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...
3
4477
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 OdbcDataAdapter("select * from TABLE1 where TABLE1.ID= '16'", "DSN=DSNTEST;UID=UIDTEST;PWD=PWDTEST;")
10
2752
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 values of A are used to populate the grid via a DataView. The instance of form2 is called Matrix_A . The basic layout is as follows: #Region "Globals Dim A As Double(,) Dim Matrix_A As form2 #End Region
2
1425
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 for changes (Calls from an external application). I am not sure if this has anything to do with it, but for some reason, the memory usage goes up about 160K just about every second (watching in Task Manager).
1
2476
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 datatable, the "independently" declared datarow is not destroyed. Is this difference in operation of datatable vs. dataset by design or a Microsoft error? Private drOriginal As DataRow 'independently declared datarow within same form
6
28328
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 DataTable. I've tried a few variations of the following but no rows are every imported into the datatable: DataRow datrow = ds.Tables.Select("PersonID = " + id); DataTable dt = new DataTable();
11
1492
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 some amount of memory, however I expected that this amount of memory will be fixed and will depend on number of user. When I put code in production I discovered that aspnet_wp.exe increases memory which it uses. Each second 2meg. What may be the...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.