Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-330

Calling getMetaData() without closing the connection lead to a memory leak

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4
    • 1.4.1
    • None

    Description

      In my program, I am using a BasicDataSource to get my database connections. I have to keep one of the connection alive and thus never close it. On this connection, I have to periodically get the metadata (call the getMetaData() method) for my processing.
      However, I have noticed that each call to this method create a new DelegatingDatabaseMetaData instance which can't be garbage collected until the connection is closed. This creation of DelegatingDatabaseMetaData will finally consume all the memory and generate a OutOfMemory error.

      Actually, in it's constructor, the DelegatingDatabaseMetaData class calls its super constructor (from the AbandonedTrace class) which creates a reference (parent.addTrace(this) from the connection to the DelegatingDatabaseMetaData. This reference prevent the DelegatingDatabaseMetaData to be collected until the Connection is closed.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              marett Timothee Maret
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: