FIX: A memory leak occurs when you use SQL Server Native Client 10.5 to run prepared statements in an instance of SQL Server

Article translations Article translations
Article ID: 2422010 - View products that this article applies to.
Microsoft distributes Microsoft SQL Server 2008 R2 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release.
Expand all | Collapse all

SYMPTOMS

Considering the following scenario:
  • You install SQL Server Native Client 10.5 on a computer.
  • You run an application that uses the SQL Server Native Client ODBC driver to connect to an instance of SQL Server.
  • A prepared statement is executed in the application multiple times.
    Note When the statement is executed, the sp_prepare and the sp_prepexec stored procedures are used.
  • You use the SQLFreeStmt ODBC API function to release the handles of the prepared statements.

In this scenario, a memory leak may occur in the instance of SQL Server.

CAUSE

This issue occurs because the SQLFreeStmt ODBC API function does not release the handles of the prepared statements.

RESOLUTION

The fix for this issue was first released in Cumulative Update 5. For more information about how to obtain this cumulative update package for SQL Server 2008 R2, click the following article number to view the article in the Microsoft Knowledge Base:
2438347 Cumulative Update package 5 for SQL Server 2008 R2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
981356 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 was released

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

The SQL Server Native Client ODBC driver supports all defined values for the Option argument in the SQLFreeStmt ODBC API function. However, it is best not to use SQLFreeStmt in ODBC 3.0 or in later versions of ODBC. 

The SQLCloseCursor, SQLBindParameter, SQLBindCol, SQLSetDescField, and SQLFreeHandle ODBC API functions replace or duplicate the function of SQLFreeStmt. Therefore, we recommend that you use these functions instead of the SQLFreeStmt function.

For more information, visit the following Microsoft websites:

Prepared Execution ODBC

SQLPrepare Function

SQLFreeStmt Function

SQLFreeHandle Function

REFERENCES

For more information about the Incremental Servicing Model for SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:
935897 An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:
822499 New naming schema for Microsoft SQL Server software update packages
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates

Properties

Article ID: 2422010 - Last Review: December 22, 2010 - Revision: 2.0
APPLIES TO
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Express
  • Microsoft SQL Server 2008 R2 Standard
  • Microsoft SQL Server 2008 R2 Web
  • Microsoft SQL Server 2008 R2 Workgroup
  • Microsoft SQL Server 2008 R2 Standard Edition for Small Business
Keywords: 
kbqfe kbfix kbsurveynew kbexpertiseadvanced KB2422010

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com