Memory Issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a program which is looping through a data reader, taking the record
which is read, creating an instance of a class which respresents that record,
and then inserting that record into a database.

As I am looking at the task manager in the performance tab, the PF Usage
continues to rise until the machine halts with a unavailable memory error.

The procedures which insert the record are all static methods. The only
substative thing which I can see which would/should be eating at the memory
is the creation of an instance of the class which holds the row in the table.
After I am done inserting the record, is there something I need to do to
remove the record from memory? Why would PF Usage continue to rise and
seeminly never drop size?

Here is an example of my loop.....


while (dr.Read())
{
readCnt++;
switch (tblToCopy)
{
case "PS_ALLOC_STEP_TBL":
PS_ALLOC_STEP_TBL rec = new
DBUtilities.GL.Tables.PS_ALLOC_STEP_TBL(dr);
ok =
PS_ALLOC_STEP_TBL_DAL.Insert_PS_ALLOC_STEP_TBL(cmTo, rec);
break;
}
if (!ok)
{ TerminateProcessing(); }
}
dr.Close();

Thanks in advance for your assistance!
 
Try using a DataSet and closing the connection. Reader keeps the connection
open.
Peter
 
Seem that creating a dataset would agrevate the problem and not make it
better as if you create a dataset and itterate over the dataset, you have to
have enough memory to hold all of the records retrieved in addition to the
existing memory issue of taking each one of those records and creating an
instance of a class for that row and then inserting it into the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top