FIX: OLE Automation BSTR caching will cause memory leak sources in Windows 2000

Article translations Article translations
Article ID: 139071 - View products that this article applies to.
This article was previously published under Q139071
Expand all | Collapse all

SUMMARY

This article describes the following about this hotfix release:
  • The issues that are fixed by the hotfix package.
  • The prerequisites that are required to install the hotfix package.
  • Whether you must restart the computer after you install the hotfix package.
  • Whether the hotfix package is replaced by any other hotfix package.
  • Whether you must make any registry changes.
  • The files that are contained in the hotfix package.

SYMPTOMS

Automation (previously called OLE Automation and ActiveX Automation) caches the space allocated for BSTR strings. This may cause IMallocSpy to attribute memory leaks to the wrong BSTR user in an application that uses Automation's BSTR strings. The correct source of the leak can be found by disabling Automation's cache by setting the environment variable OANOCACHE=1 before running the application. In many server-based applications, the BSTR cache is not required. There is a hotfix available to disable BSTR caching on Windows 2000 computers. Windows XP and Windows Server 2003 do not require the hotfix to disable BSTR caching.

RESOLUTION

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

Prerequisites

You must have installed Windows 2000 Service Pack 4 (SP4) to apply this hotfix.

Restart information

You must restart the computer after you apply this hotfix.

Registry information

You do not have to change the registry.

Hotfix file information

This hotfix contains only those files that are required to correct the issues that this article lists. This hotfix may not contain of all the files that you must have to fully update a product to the latest build. The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatform
Asycfilt.dll2.40.4528.0143,63211-Sep-200513:05x86
Oleaut32.dll2.40.4528.0631,05611-Sep-200513:05x86
Olepro32.dll5.0.4528.0164,11211-Sep-200513:05x86
Stdole2.tlb2.40.4528.016,89623-Aug-200502:13

STATUS

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

MORE INFORMATION

Automation caches the space allocated for BSTRs. This speeds up the SysAllocString/SysFreeString sequence. However, this may cause IMallocSpy to attribute leaks to the wrong memory user because it is not aware of the caching that Automation performs. For example, if the application allocates a BSTR and frees it, the freed block of memory is put into the BSTR cache by Automation. If the application then allocates another BSTR, it may receive the free block from the cache. If the second BSTR allocation is not freed, IMallocSpy will attribute the leak to the first allocation of the BSTR. The correct leak source (the second allocation) can be determined by disabling the BSTR caching that Automation performs. You can do this by setting environment variable OANOCACHE=1 before you run the application. On Windows 2000, the hotfix version of oleaut32.dll referenced in this article is required. It is also important to look for leaks at the correct time to prevent false leak reports. These leaks may occur when the IMallocSpy implementation checks for leaks too soon. Users of memory that is allocated by IMalloc can legitimately hold on to it after OleUninitialize. For example, the Automation BSTR cache is deleted at the Oleaut32.dll file's DLL_PROCESS_DETACH time. This means that checking for leaks immediately after OleUninitialize may cause false reports of memory leaks. A good place to look for memory leaks is in the destructor of a static instance of a class, that implements IMallocSpy. The destructor of this static instance is called after the DllMain of each DLL linked by the application is called with DLL_PROCESS_DETACH.

Set the OANOCACHE environment variable

  1. In Control Panel, double-click the System icon. The System Properties dialog box appears.
  2. On the Advanced tab, click Environment Variables. The Environment Variables dialog box appears.
  3. Under System variables, click New. The New System Variable dialog box appears.
  4. Type OANOCACHE in the Variable Name box.
  5. Type 1 in the Variable Value box.
  6. Click OK three times.
Before you change the OANOCACHE environment variable, you must stop the following server processes if they are running:
  • The Inetinfo process
  • The Dllhost process
  • The W3wp process
  • The Aspnet_wp process
Note If you are not sure whether these server processes are running, set the environment variable OANOCACHE=1, and then restart the computer.

REFERENCES

For more information, 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: 139071 - Last Review: September 17, 2011 - Revision: 6.0
APPLIES TO
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
Keywords: 
kbautohotfix kbhotfixserver kbqfe kbexpertiseadvanced kbfix kbautomation KB139071

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