PRB: Visual Basic DLL Has Memory Leaks and Crashes in COM+ If 'Retain In Memory' Is Not Set (264957)



The information in this article applies to:

  • Microsoft COM+ 1.0
  • Microsoft COM+ 1.5
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Transaction Server 2.0

This article was previously published under Q264957

SYMPTOMS

The Visual Basic 6.0 ActiveX DLL may cause COM+ applications and Active Server Pages (ASP) to stop responding (crash or hang) if you do not select the Unattended Execution and Retain in Memory options.

CAUSE

Visual Basic runtime behaves differently based on whether you select the Unattended Execution and the Retain in Memory options are selected. When you do not select these options, the Visual Basic runtime unloads custom and runtime DLLs unexpectedly, which causes the computer to stop responding (crash or hang) under some multithreaded scenarios. Typical scenarios include when you place the ActiveX DLL in COM+ or Microsoft Transaction Server (MTS), or when you call the ActiveX DLL from ASP pages.

Note As in many multithreading issues, the symptoms may only manifest themselves under very specific and transient conditions.

RESOLUTION

To resolve this problem, set the Retain In Memory option as follows:
  1. From the Project menu, select Project Properties.
  2. On the General tab, select the Unattended Execution and Retain In Memory checkboxes.
Note The Unattended Execution option is not available if the project contains any user interface elements, such as forms or controls. The Retain in Memory option is not available if Unattended Execution is not selected.

Note Before Service Pack 3 for Visual Studio 6.0, it was possible to get an access violation during process shutdown with Retain in Memory enabled. This has been fixed in Visual Studio 6.0, Service Pack 3 or later.

STATUS

This behavior is by design.
Note In Visual Studio 6, Service Pack 5, when a project contains any public class that has MTSTransactionMode set to anything other than 0, the Unattended Execution and Retain In Memory options are automatically selected.

REFERENCES

For a comprehensive list of guidelines and tips about how to develop COM+ applications with Visual Basic, visit the following Microsoft Developer Network (MSDN) Web site:For additional information on threading issues with Visual Basic 6.0 ActiveX components, click the article number below to view the article in the Microsoft Knowledge Base:

241896 PRB: Threading Issues with Visual Basic 6.0 ActiveX Components

For additional information on threading issues with Visual Basic 5.0 ActiveX components, see the following article:

186273 BUG: AV Running VB-Built Component in Multi-Threaded Environment


Modification Type:MinorLast Reviewed:3/21/2003
Keywords:kbGuidelines kbnofix kbprb kbThread KB264957