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

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

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:
http://msdn.microsoft.com/en-us/library/ms809241.aspx
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

Properties

Article ID: 264957 - Last Review: December 5, 2007 - Revision: 1.6
APPLIES TO
  • Microsoft COM+ 1.0
  • Microsoft COM+ 1.5
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Transaction Services 2.0
Keywords: 
kbguidelines kbnofix kbprb kbthread KB264957

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