FIX: Oracle OLE DB Provider May Leak Memory When Executing Certain Stored Procedures (314637)



The information in this article applies to:

  • Microsoft Data Access Components 1.5
  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.6 SP1
  • Microsoft OLE DB Provider for Oracle 2.6
  • Microsoft Data Access Components 2.6 SP2
  • Microsoft OLE DB Provider for Oracle 2.0
  • Microsoft OLE DB Provider for Oracle 2.1
  • Microsoft OLE DB Provider for Oracle 2.5

This article was previously published under Q314637

SYMPTOMS

The Microsoft OLE DB Provider for Oracle may leak memory when used to execute a stored procedure against Oracle that returns extra output parameters after a result set.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.  This bug was corrected in Microsoft Data Access Components (MDAC) 2.7.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Execute the following script to create a sample table and stored procedure in an Oracle database:
    DROP TABLE person;
    
       CREATE TABLE person
        (ssn     NUMBER(9) PRIMARY KEY,
         fname   VARCHAR2(15),
         lname   VARCHAR2(20));
    
       INSERT INTO person VALUES(555662222,'Sam','Goodwin');
    
       INSERT INTO person VALUES(555882222,'Kent','Clark');
    
       INSERT INTO person VALUES(666223333,'Jane','Doe');
    
       COMMIT;
        / 
    CREATE OR REPLACE PACKAGE packperson
         AS
           TYPE tssn is TABLE of  NUMBER(10)
           INDEX BY BINARY_INTEGER;
           TYPE tfname is TABLE of VARCHAR2(15)
           INDEX BY BINARY_INTEGER;
           TYPE tlname is TABLE of VARCHAR2(20)
           INDEX BY BINARY_INTEGER;
    
           PROCEDURE allperson
                   (param1 IN NUMBER,
    	  ssn    OUT     tssn,
                    fname  OUT     tfname,
                    lname  OUT     tlname,
    	 param2  OUT  NUMBER);
       END packperson;
    / 
    
       CREATE OR REPLACE PACKAGE BODY packperson
       AS
    
       PROCEDURE allperson
                  (param1 IN NUMBER,
    	  ssn    OUT     tssn,
                    fname  OUT     tfname,
                    lname  OUT     tlname,
    	 param2  OUT  NUMBER)
      
       IS
           CURSOR person_cur IS
                   SELECT ssn, fname, lname
                   FROM person;
    
           percount NUMBER DEFAULT 1;
    
       BEGIN
           FOR singleperson IN person_cur
           LOOP
                   ssn(percount) := singleperson.ssn;
                   fname(percount) := singleperson.fname;
                   lname(percount) := singleperson.lname;
                   percount := percount + 1;
           END LOOP;
           param2:=param1;
       END;
    END;
    					
  2. Insert the following code into the form code for a new Microsoft Visual Basic 6.0 Data Project:
    Private Sub Form_Load()
        While True
            LeakDemo
        Wend
    End Sub
    
    Private Sub LeakDemo()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim cmd As New ADODB.Command
        
        cn.Open "Provider=MSDAORA;Data Source=MyOracleDataSource;", "MyUser_Name", "MyPassword"
        Set cmd.ActiveConnection = cn
        cmd.CommandType = adCmdText
        cmd.CommandText = "{call packperson.allperson(?,{resultset 500,SSN,FNAME,LNAME},?)}"
        cmd.Parameters.Append cmd.CreateParameter("DUMMY", adInteger, adParamInput, 4, 0)
        cmd.Parameters.Append cmd.CreateParameter("DUMMY_OUT", adInteger, adParamOutput, 0)
        
        Set rs = cmd.Execute
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = Nothing
        Set cmd = Nothing
    End Sub
    					
  3. Use Performance Monitor to monitor the private bytes on the Visual Basic 6.0 process (or your executable process). You will notice a gradual, steady increase in the number of private bytes allocated for the process.

Modification Type:MinorLast Reviewed:11/4/2003
Keywords:kbbug kbfix kbOracle kbQFE KB314637