Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:48:02+00:00 2026-05-20T10:48:02+00:00

I am investigating an issue with a .net 1.1 web application where it seems

  • 0

I am investigating an issue with a .net 1.1 web application where it seems that we had quite a few “Internal connection fatal error” exceptions possibly the connection objects staying open or not disposed of properly. The web server eventually crashes under heavy load. I checked the code and we are in fact calling sqlconnection.close() in all places in the try catch finally

The project implements the following pattern. Can someone tell me if it looks like this may cause a memory leak?

The aspx webpage makes the following call in Private Sub Page_Load

Dim oDictionary As New dbDictionary
tagVal = oDictionary.GetTag(41)

where dbDictionary is used for getting a sql table from DB

Public Class dbDictionary
    Inherits DBInteractionBase

Public Function GetTag(ByVal tagId)

       'uses the  _connection connection object and Executes sql which sometimes throws a sql exception, but closes the connection in finally

        GetDictConnectionString()

         'new sqlconnection object for another sqlcommand
        Dim dictConnection As New SqlConnection
        dictConnection = _connection  'At this point the _connection is closed.

        'I think the dictConnection is a reference to _connection

        Dim cmdToExecute As SqlCommand = New SqlCommand

        ' // Use base class' connection object
        cmdToExecute.Connection = dictConnection

        Try
            ' // Open connection.
            dictConnection.Open()

            ' // Execute query.
            adapter.Fill(toReturn)


        Catch ex As Exception
            Throw New Exception("Error occured.", ex)
        Finally
            ' // Close connection.
            dictConnection.Close()
            cmdToExecute.Dispose()
            adapter.Dispose()
        End Try


    End Function

    Private Function GetDictConnectionString()


        ' initialize SqlCommand... Use base class _connection object
        cmdToExecute.Connection = _connection

        Try
            _connection.Open()
            adapter.Fill(toReturn)

        Catch ex As Exception
            Return "Error" ' Could this be the issue?  The original exception isn't released?
        Finally
            _connection.Close()
            cmdToExecute.Dispose()
            adapter.Dispose()
        End Try

End Class

Here is the DBInteractionBase that it inherits

Public MustInherit Class DBInteractionBase
    Inherits System.Web.UI.Page

Protected _connection As SqlConnection

    Public Sub New()

         _connection = New SqlConnection
         _connection.ConnectionString = "some conn string"
            End Sub

    Public Overloads Sub Dispose()
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub


    Protected Overridable Overloads Sub Dispose(ByVal isDisposing As Boolean)
        ' // Check to see if Dispose has already been called.
        If Not _isDisposed Then
            If isDisposing Then
                ' // Dispose managed resources.
                _connection.Dispose()
                _connection = Nothing
            End If
        End If
        _isDisposed = True
    End Sub

Now when the code is executing, the Dispose never gets called by the calling web page. What I am wondering is if the dispose code ever gets executed by the GC? Another issue I see possibly is that if GetDictConnectionString has an exception, it never rethrows the original sql exception. Would that somehow leave the sql object in memory? Keep in mind this is a .NET 1.1 application and (GC in .NET 1 is not very efficient)

Also I am wondering what I can monitor on the web server using perfmon to indicate a memory leak. I am planning on modifying this code and would like an indicator that the issue was fixed. I see a trend in SqlClient: Current # connection pools – it’s growing steadily 1000 each day (It’s Current number of pools associated with the process.) so I am wondering if it should go down as the Sessions decrease. I am looking at (\ASP.NET Apps v1.1.4322(Total)\Sessions Active) to see what the server load looks like.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:48:03+00:00Added an answer on May 20, 2026 at 10:48 am

    This code:

    'new sqlconnection object for another sqlcommand
    Dim dictConnection As New SqlConnection
    dictConnection = _connection  'At this point the _connection is closed.
    

    Is creating two SqlConnections (the As New SqlConnection is creating one), and the first would never be disposed. This could certainly be a source of leaking connections.

    You’re also disposing of the connection _connection that you never created (can’t see where this is being created). Assuming it’s being created 1:1 this shouldn’t be a huge problem, but if an exception occurs before your Try block, this connection will also not be disposed. If _connection is not being created 1:1 for this code, you might end up getting ObjectDisposedException if something else tries to use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am investigating GDI leaks issue in one of our smart-client application. I am
Sometime ago for my asp.net application I have added a web service. After some
Whilst investigating a memory leak I discovered that it was caused by calling NewRow()
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
We are investigating using CruiseControl.NET as both a Continues Integration build provider, as well
I'm investigating a serious performance problem in my OSGi-based application which is using Eclipselink
While investigating a reported problem with my site loading slowly, I came across an
I am investigating the design of a work queue processor where the QueueProcessor retrieves
I'm investigating the differences between using log4net and System.Diagnostics.Trace for logging, and I'm curious
I'm investigating an annotation-based approach to validating Spring beans using spring modules . In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.