Problem Open Object

Discussion in 'ASP General' started by stuart, Jul 20, 2005.

  1. stuart

    stuart Guest

    Hi,

    I think I have a memory leak on a web site I built.
    The site runs for 6 weeks or (getting slower after about 4-5 weeks) then
    the site stops serving .asp pages (no probs with any other file type).

    I think I have forgotten to destroy a recordset or connection , but I
    cannot find any offending code.

    Is there a function that I could use along the lines of: -

    for Each object in openObjects

    response.write object.Name

    OR

    object.close
    set object = nothing

    next

    TIA

    Stuart
     
    stuart, Jul 20, 2005
    #1
    1. Advertising

  2. No, unfortunately there is not. If you consistently name your ADO object
    the same thing in all your pages, what you can do is create a file like
    this:

    <%

    On Error Resume Next
    yourADOObject.Close
    If Err.Number = 0 Then
    Call EmailAlert()
    Set yourADOObject = Nothing
    End If


    Sub EmailAlert()
    Dim o
    Set o = CreateObject("CDO.Message")
    o.From = "email address here"
    o.To = "email address here"
    o.Subject "Unclosed ADO Object"
    o.TextBody = "Unclosed ADO object in " & Request.ServerVariables("URL")
    o.Send
    Set o = Nothing
    End Sub

    %>


    And then use a good text editor, i.e. www.textpad.com, and use it to do a
    global replace in your site to add a virtual include to all your ASP files
    at the very EOF. If you have a popular site, you should start getting
    e-mails telling you about pages with unclosed ADO objects. Of course, this
    does assume that you consistently name your ADO objects the same thing...
    This in no way is a perfect solution...

    Ray at home


    "stuart" <> wrote in message
    news:%...
    > Hi,
    >
    > I think I have a memory leak on a web site I built.
    > The site runs for 6 weeks or (getting slower after about 4-5 weeks) then
    > the site stops serving .asp pages (no probs with any other file type).
    >
    > I think I have forgotten to destroy a recordset or connection , but I
    > cannot find any offending code.
    >
    > Is there a function that I could use along the lines of: -
    >
    > for Each object in openObjects
    >
    > response.write object.Name
    >
    > OR
    >
    > object.close
    > set object = nothing
    >
    > next
    >
    > TIA
    >
    > Stuart
     
    Ray Costanzo [MVP], Jul 21, 2005
    #2
    1. Advertising

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.

Share This Page