running out of memory

Discussion in 'Microsoft ADO .NET' started by Guest, Apr 6, 2005.

  1. Guest

    Guest Guest

    Hi;

    I have to write custom data integrity utilities comparing files with table
    data.
    I've found that looping through an ado recordset will cause memory problems
    if it's a large recordset.

    I'm using this sort of syntax:

    adoRSdir = adocn.Execute(sSQL, lrecs)

    Do Until adoRSdir.EOF = True
    'this loop is running out of memory
    Loop

    How can you monitor if you're going to run out of memory?
    What technique would be better other than narrowing the sql
    querystring result set?

    Thanks for your knowledge.

    Best Regards;

    Todd
     
    Guest, Apr 6, 2005
    #1
    1. Advertisements

  2. Hi,

    First of all it is not ADO, but ADO.NET newsgroup. Maybe you should consider
    using of the SQL statements on a server side inside of SP to do this rather
    than looping through the records. What do you need to achieve?

    --
    Val Mazur
    Microsoft MVP

    http://xport.mvps.org



    "Supertree" <> wrote in message
    news:...
    > Hi;
    >
    > I have to write custom data integrity utilities comparing files with table
    > data.
    > I've found that looping through an ado recordset will cause memory
    > problems
    > if it's a large recordset.
    >
    > I'm using this sort of syntax:
    >
    > adoRSdir = adocn.Execute(sSQL, lrecs)
    >
    > Do Until adoRSdir.EOF = True
    > 'this loop is running out of memory
    > Loop
    >
    > How can you monitor if you're going to run out of memory?
    > What technique would be better other than narrowing the sql
    > querystring result set?
    >
    > Thanks for your knowledge.
    >
    > Best Regards;
    >
    > Todd
    >
     
    Val Mazur \(MVP\), Apr 7, 2005
    #2
    1. Advertisements

  3. Guest

    Alex Passos Guest

    Hi, take a look at this article it discusses some code optimization
    strategies:

    http://www.vbip.com/books/1861002610/chapter_2610_07.asp

    And if you are using SQL Server you can also limit your query with something
    like

    SELECT TOP 100 ....

    And then change your condition such as greater than the value of the 100th
    row for the next query.
    Make sure that from iteration to iteration you are closing the recordset and
    releasing its memory by setting it to null when the iteration completes.

    Alex

    "Supertree" <> wrote in message
    news:...
    > Hi;
    >
    > I have to write custom data integrity utilities comparing files with table
    > data.
    > I've found that looping through an ado recordset will cause memory
    > problems
    > if it's a large recordset.
    >
    > I'm using this sort of syntax:
    >
    > adoRSdir = adocn.Execute(sSQL, lrecs)
    >
    > Do Until adoRSdir.EOF = True
    > 'this loop is running out of memory
    > Loop
    >
    > How can you monitor if you're going to run out of memory?
    > What technique would be better other than narrowing the sql
    > querystring result set?
    >
    > Thanks for your knowledge.
    >
    > Best Regards;
    >
    > Todd
    >
     
    Alex Passos, Apr 7, 2005
    #3
  4. Guest

    Guest Guest

    This suggestion from Stephen Howe worked.

    If same machine:
    Same thing applies but now you are aware that your SQL request may cause
    your database considerable overhead depending on complexity of request. I
    would be tempted to do

    adoRSdir.Open(SQLRequest,,,,) etc

    Thanks for your responses:

    "Val Mazur (MVP)" wrote:

    > Hi,
    >
    > First of all it is not ADO, but ADO.NET newsgroup. Maybe you should consider
    > using of the SQL statements on a server side inside of SP to do this rather
    > than looping through the records. What do you need to achieve?
    >
    > --
    > Val Mazur
    > Microsoft MVP
    >
    > http://xport.mvps.org
    >
    >
    >
    > "Supertree" <> wrote in message
    > news:...
    > > Hi;
    > >
    > > I have to write custom data integrity utilities comparing files with table
    > > data.
    > > I've found that looping through an ado recordset will cause memory
    > > problems
    > > if it's a large recordset.
    > >
    > > I'm using this sort of syntax:
    > >
    > > adoRSdir = adocn.Execute(sSQL, lrecs)
    > >
    > > Do Until adoRSdir.EOF = True
    > > 'this loop is running out of memory
    > > Loop
    > >
    > > How can you monitor if you're going to run out of memory?
    > > What technique would be better other than narrowing the sql
    > > querystring result set?
    > >
    > > Thanks for your knowledge.
    > >
    > > Best Regards;
    > >
    > > Todd
    > >

    >
    >
    >
     
    Guest, Apr 7, 2005
    #4
  5. Guest

    Guest Guest

    This suggestion from Stephen Howe worked.

    If same machine:
    Same thing applies but now you are aware that your SQL request may cause
    your database considerable overhead depending on complexity of request. I
    would be tempted to do

    adoRSdir.Open(SQLRequest,,,,) etc

    Thanks for your responses:

    "Alex Passos" wrote:

    > Hi, take a look at this article it discusses some code optimization
    > strategies:
    >
    > http://www.vbip.com/books/1861002610/chapter_2610_07.asp
    >
    > And if you are using SQL Server you can also limit your query with something
    > like
    >
    > SELECT TOP 100 ....
    >
    > And then change your condition such as greater than the value of the 100th
    > row for the next query.
    > Make sure that from iteration to iteration you are closing the recordset and
    > releasing its memory by setting it to null when the iteration completes.
    >
    > Alex
    >
    > "Supertree" <> wrote in message
    > news:...
    > > Hi;
    > >
    > > I have to write custom data integrity utilities comparing files with table
    > > data.
    > > I've found that looping through an ado recordset will cause memory
    > > problems
    > > if it's a large recordset.
    > >
    > > I'm using this sort of syntax:
    > >
    > > adoRSdir = adocn.Execute(sSQL, lrecs)
    > >
    > > Do Until adoRSdir.EOF = True
    > > 'this loop is running out of memory
    > > Loop
    > >
    > > How can you monitor if you're going to run out of memory?
    > > What technique would be better other than narrowing the sql
    > > querystring result set?
    > >
    > > Thanks for your knowledge.
    > >
    > > Best Regards;
    > >
    > > Todd
    > >

    >
    >
    >
     
    Guest, Apr 7, 2005
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frode Rislaa

    Aborting long running queries/Running queries asynchronous

    Frode Rislaa, Aug 6, 2003, in forum: Microsoft ADO .NET
    Replies:
    0
    Views:
    599
    Frode Rislaa
    Aug 6, 2003
  2. Guest
    Replies:
    2
    Views:
    863
    Guest
    Nov 20, 2003
  3. Bob
    Replies:
    0
    Views:
    303
  4. Guest
    Replies:
    3
    Views:
    316
    Guest
    May 18, 2004
  5. DR
    Replies:
    3
    Views:
    281
    Miha Markic
    Apr 20, 2008
Loading...

Share This Page