Microsoft KB Archive/264957

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

Article ID: 264957

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.0
 * Microsoft COM+ 1.5
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Transaction Services 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.

