PC Review


Reply
Thread Tools Rate Thread

Application Eating up Memory

 
 
news
Guest
Posts: n/a
 
      28th May 2008
Hi,

I have a C# application (Visual Studio 2005) that invloves reading a large amount of data from SQL server (in this case SQL 2005). Here is what I am trying to do.

//declare a data set obeject
DataSet accountRecord = new DataSet();
DataSet oDS = new DataSet();

//query database useing the OdbcConnection connection

//loop thru all the records

//insert a new row in another database. assuming the connection exists
odr = oDS.Tables[0].NewRow();

odr[field name] = value;

//update dataset
oDS.Tables[0].Rows.Add(odr);

//save data in table.
oAdapter.Update(oDS);

//end loop

When the internal loop is being executed the memory usage goes on increasing till I get an System.OutOfMemory exception. Can you tell me the cause of the memory increasing in the for loop. Please let me know if you need more information.

Sincerely,
Saurabh




 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      28th May 2008
Couple of ideas here. You don't have complete code in your sample, so it's hard to tell what exactly is going on.

1. Why ODBC? If you are talking to SQL Server, the SQLClient class and SqlConnection object will be more efficient.

2. It seems that what you are doing is adding a row to a Datatable and using the DataAdapter Update method to insert a new row in a table. Why not just do a direct insert with ExecuteNonQuery? It's more efficient.

3. Make sure you observe best practices by opening your connection immediately before use and closing it immediately after. This returns the connection object to the connection pool, and is most likely the cause of your problems.

-Peter
"news" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
Hi,

I have a C# application (Visual Studio 2005) that invloves reading a large amount of data from SQL server (in this case SQL 2005). Here is what I am trying to do.

//declare a data set obeject
DataSet accountRecord = new DataSet();
DataSet oDS = new DataSet();

//query database useing the OdbcConnection connection

//loop thru all the records

//insert a new row in another database. assuming the connection exists
odr = oDS.Tables[0].NewRow();

odr[field name] = value;

//update dataset
oDS.Tables[0].Rows.Add(odr);

//save data in table.
oAdapter.Update(oDS);

//end loop

When the internal loop is being executed the memory usage goes on increasing till I get an System.OutOfMemory exception. Can you tell me the cause of the memory increasing in the for loop. Please let me know if you need more information.

Sincerely,
Saurabh




 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      29th May 2008
news wrote:
> I have a C# application (Visual Studio 2005) that invloves reading a
> large amount of data from SQL server (in this case SQL 2005). Here is
> what I am trying to do.
>
> //declare a data set obeject
> DataSet accountRecord = new DataSet();
> DataSet oDS = new DataSet();
>
> //query database useing the OdbcConnection connection
>
> //loop thru all the records
>
> //insert a new row in another database. assuming the connection exists
> odr = oDS.Tables[0].NewRow();
>
> odr[field name] = value;
>
>
> //update dataset
> oDS.Tables[0].Rows.Add(odr);
>
> //save data in table.
> oAdapter.Update(oDS);
>
> //end loop
>
> When the internal loop is being executed the memory usage goes on
> increasing till I get an System.OutOfMemory exception. Can you tell me
> the cause of the memory increasing in the for loop. Please let me know
> if you need more information.


DataSet and "large amount of data" does not match well.

A DataSet has all data in memory, so if data are in many GB size, then
you will run out of virtual memory on a 32 bit Windows and out
of pagefile on a 64 bit Windows.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
w3wp.exe (ASP .Net) eating memory venom00 Microsoft ASP .NET 3 18th Nov 2009 08:13 AM
IE is eating up all my memory =?Utf-8?B?QXJsZW4=?= Windows XP Accessibility 4 25th Aug 2006 05:46 PM
Is SP2 memory eating? Juergen Windows XP General 2 11th Sep 2004 09:10 AM
Re: ADO.NET Eating Up Memory Byron Hopp Microsoft ADO .NET 1 19th Jul 2003 06:02 PM
Re: ADO.NET Eating Up Memory Cowboy \(Gregory A. Beamer\) Microsoft ADO .NET 0 8th Jul 2003 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:50 AM.