I am loading a weeks worth of web logs into a dataset using Imports Microsoft.Data. Odbc
These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this
Dim dt As New DataTable()
Dim cnString As String
Dim adapter As New OdbcDataAdapter ()
Dim qs1 As String = "Select * from dl" 'first part of query
....
....
....
While ReadDate < DTEnd 'make query and fill adapter for each selected period
query = Format(ReadDate , "yyyyMMdd") + "#txt" 'construct query
nqs1 = Replace(qs1, "*", "'" + DepName + "' as TName,*") 'add department name to record
query = nqs1 + query 'add first part to query
Try
adapter.SelectC ommand = New OdbcCommand(que ry, conn)
adapter.Fill(ds , TableName) 'get records from logs
Catch ex As Exception
EMsg += query + vbCrLf + cnString + vbCrLf + ex.ToString + vbCrLf + vbCrLf
MsgBox(EMsg)
End Try
ReadDate = DateAdd(DateInt erval.Day, 1, ReadDate) 'inc process date
frmMon.Label6.T ext = ds.Tables(Table Name).Rows.Coun t.ToString
frmMon.Label6.R efresh()
End While
I then set the table to a view and then bind to a datagrid
dv = ds.Tables(0).De faultView
frmDG.DataGrid1 .DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs trying to execute the adapter.fill
I modified the app so that a new table "TableName" is sent each time I run the process and this works well ---- but
The memory utilization just keeps increasing until I stop the app. (approx 20Mb per pass.
So I have tried some of the following
ds.Tables.Remov e(tn)
ds.Tables(tn).D ispose()
Me.ds.Tables(0) .Rows.Clear()
Me.ds.Clear()
Me.dt.Rows.Clea r()
Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload the dataset without changing the name of the datatable
Anyone have ideas on how to release the memory being used to hold the data from the last adapter.fill? 4 4312
Hi Slaprade,
Before I answer go to deep in your question, when there is a process as you
show it is normal that the memory increases. It will be freeed when the
Garbage Collector GC starts. However because this is a process withouth that
the control is given to something else, this can take something longer.
The GC starts when there is time or that there is memory needed. Therefore
my question is first, what is the problem with using available memory?
Cor I am loading a weeks worth of web logs into a dataset using Imports
Microsoft.Data. Odbc These are text - fixed length fields so I have written a schema for them.
The adapter fill looks like this Dim dt As New DataTable() Dim cnString As String Dim adapter As New OdbcDataAdapter () Dim qs1 As String = "Select * from dl" 'first part of query
... ... ...
While ReadDate < DTEnd 'make query and fill adapter for
each selected period query = Format(ReadDate , "yyyyMMdd") + "#txt"
'construct query nqs1 = Replace(qs1, "*", "'" + DepName + "' as
TName,*") 'add department name to record query = nqs1 + query 'add first part to query Try adapter.SelectC ommand = New OdbcCommand(que ry,
conn) adapter.Fill(ds , TableName) 'get records from logs Catch ex As Exception EMsg += query + vbCrLf + cnString + vbCrLf +
ex.ToString + vbCrLf + vbCrLf MsgBox(EMsg) End Try ReadDate = DateAdd(DateInt erval.Day, 1, ReadDate) 'inc
process date frmMon.Label6.T ext =
ds.Tables(Table Name).Rows.Coun t.ToString frmMon.Label6.R efresh() End While
I then set the table to a view and then bind to a datagrid dv = ds.Tables(0).De faultView frmDG.DataGrid1 .DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs
trying to execute the adapter.fill I modified the app so that a new table "TableName" is sent each time I run
the process and this works well ---- but The memory utilization just keeps increasing until I stop the app. (approx
20Mb per pass. So I have tried some of the following
ds.Tables.Remov e(tn) ds.Tables(tn).D ispose() Me.ds.Tables(0) .Rows.Clear() Me.ds.Clear() Me.dt.Rows.Clea r() Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload
the dataset without changing the name of the datatable Anyone have ideas on how to release the memory being used to hold the data
from the last adapter.fill?
Well - as long as memory is available there is no big problem - After 6 iterations through this routine (6 weeks of data) I read approx 500Mb of memory in use.. I am concerned that if I had to run this app for a years worth of weeks that a significant amount of time would be spent in disk writes
But more to the point - I quess I just like to keep my apps as trim and fast as possible - More a Felix Unger thing
"Cor Ligthert" wrote: Hi Slaprade,
Before I answer go to deep in your question, when there is a process as you show it is normal that the memory increases. It will be freeed when the Garbage Collector GC starts. However because this is a process withouth that the control is given to something else, this can take something longer.
The GC starts when there is time or that there is memory needed. Therefore my question is first, what is the problem with using available memory?
Cor
I am loading a weeks worth of web logs into a dataset using Imports Microsoft.Data. Odbc These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this Dim dt As New DataTable() Dim cnString As String Dim adapter As New OdbcDataAdapter () Dim qs1 As String = "Select * from dl" 'first part of query
... ... ...
While ReadDate < DTEnd 'make query and fill adapter for each selected period query = Format(ReadDate , "yyyyMMdd") + "#txt" 'construct query nqs1 = Replace(qs1, "*", "'" + DepName + "' as TName,*") 'add department name to record query = nqs1 + query 'add first part to query Try adapter.SelectC ommand = New OdbcCommand(que ry, conn) adapter.Fill(ds , TableName) 'get records from logs Catch ex As Exception EMsg += query + vbCrLf + cnString + vbCrLf + ex.ToString + vbCrLf + vbCrLf MsgBox(EMsg) End Try ReadDate = DateAdd(DateInt erval.Day, 1, ReadDate) 'inc process date frmMon.Label6.T ext = ds.Tables(Table Name).Rows.Coun t.ToString frmMon.Label6.R efresh() End While
I then set the table to a view and then bind to a datagrid dv = ds.Tables(0).De faultView frmDG.DataGrid1 .DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs trying to execute the adapter.fill I modified the app so that a new table "TableName" is sent each time I run
the process and this works well ---- but The memory utilization just keeps increasing until I stop the app. (approx
20Mb per pass. So I have tried some of the following
ds.Tables.Remov e(tn) ds.Tables(tn).D ispose() Me.ds.Tables(0) .Rows.Clear() Me.ds.Clear() Me.dt.Rows.Clea r() Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload
the dataset without changing the name of the datatable Anyone have ideas on how to release the memory being used to hold the data
from the last adapter.fill?
> But more to the point - I quess I just like to keep my apps as trim and
fast as possible - More a Felix Unger thing
Exactly and therefore it should not be that there is useless cleaning up of
memory in processing time, better is to do it when the computer is in idle
state or when it is really needed, what I pointed you on in my previous
message how it is done by managed code what is a big benefit of dotNet.
However my idea, when you not agree feel free for that.
Cor
Two points here:
1. Which version MDAC you have? Version 2.7 has some bugs, so Fill() hanged (with ODBCAdapter). It was repaired in ver 2.7 sp1 or sp2. Current version is 2.8.
2. Try to encapsulate code so that you create and use objects (as local variables) in subroutine and dont use them outside this subroutine. If subroutine ends and no objects are assigned to outside objects/variables then garbage collector clears them. But if subroutine gives some ponters outside (eg for form object) then try sometimes set them null (or none in VB).
Sorry, if I talked about wrong thing -- I dont see whole code here ;)
Indrek
"slaprade" wrote: I am loading a weeks worth of web logs into a dataset using Imports Microsoft.Data. Odbc These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this Dim dt As New DataTable() Dim cnString As String Dim adapter As New OdbcDataAdapter () Dim qs1 As String = "Select * from dl" 'first part of query
... ... ...
While ReadDate < DTEnd 'make query and fill adapter for each selected period query = Format(ReadDate , "yyyyMMdd") + "#txt" 'construct query nqs1 = Replace(qs1, "*", "'" + DepName + "' as TName,*") 'add department name to record query = nqs1 + query 'add first part to query Try adapter.SelectC ommand = New OdbcCommand(que ry, conn) adapter.Fill(ds , TableName) 'get records from logs Catch ex As Exception EMsg += query + vbCrLf + cnString + vbCrLf + ex.ToString + vbCrLf + vbCrLf MsgBox(EMsg) End Try ReadDate = DateAdd(DateInt erval.Day, 1, ReadDate) 'inc process date frmMon.Label6.T ext = ds.Tables(Table Name).Rows.Coun t.ToString frmMon.Label6.R efresh() End While
I then set the table to a view and then bind to a datagrid dv = ds.Tables(0).De faultView frmDG.DataGrid1 .DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs trying to execute the adapter.fill
I modified the app so that a new table "TableName" is sent each time I run the process and this works well ---- but
The memory utilization just keeps increasing until I stop the app. (approx 20Mb per pass.
So I have tried some of the following
ds.Tables.Remov e(tn) ds.Tables(tn).D ispose() Me.ds.Tables(0) .Rows.Clear() Me.ds.Clear() Me.dt.Rows.Clea r() Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload the dataset without changing the name of the datatable
Anyone have ideas on how to release the memory being used to hold the data from the last adapter.fill? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
I tried posting this in the WinForm forum and got no hits so I am
trying it here.
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the full code for the test below. Create a project drop
in the...
|
by: Hardy Wang |
last post by:
Hi,
I have a DataSet, returned by a stored procudure, which has only on
DataTable. At this step there is no sort in DataTable. Is there is a way I
can do to sort DataRows in this DataTable (not from select statement of sql
query) in memory?
Thanks
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
|
by: Arpan |
last post by:
The following code snippet creates a DataSet on the fly which is then passed to a DataView so that the DataSet can finally be viewed in a DataGrid control:
'Create the empty DataSet
Dim objDS As New DataSet("MyDataSet")=CreateDataSet()
'Create the new table & add columns
Dim dTable As New DataTable("Users")...
|
by: Bob Davies |
last post by:
Hi
I have a webservice that retrieves data from a database, this is then
returned to the calling client application built in windows forms within a
dataset, however upon attempting to create tablestyles to format any of the
columns within the datagrid, the exception "Can-not parent objects created
on one thread to objects created on...
|
by: Datatable Dataset Datagrid help |
last post by:
Hi I am somewhat confused, I am new at VB.net
I use XML data,
I have a datagrid,
I created a datatable so that I can create a custom format like true is this
graphic false is this graphic and others.
One of the custom format is as follows:
dsmessages_dt.Columns.Add("Image", GetType(Image))
I had a problem of when I used a checkbox in the...
| |
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....
I create a mydataset1...
|
by: Nathan Franklin |
last post by:
Hello Guys,
I have been trying to work this our for so long, but I just can't seem to
find the answer.
I am loading a datatable from a an access database using an
oledbdataadapter. I then assign the datatable.dataview to my
datagrid.datasource member so it will display my results..
I need to give the user an option to change the order...
|
by: =?Utf-8?B?QWxla3MgS2xleW4=?= |
last post by:
I use in my asp.net code dataset and populate datatable using dataadapter.
The problem is that my code demand huge amount of memory and I am looking
for way reduce this demand.
At this time I keep links to dataset, dataadapter and datatable in session.
As I understand datatable is class and specific datatable does not belong
directly to...
|
by: Brian |
last post by:
I want to create an In Memory dataset. not connected to any database.. but
putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |