PRB: DLLs Not Unloaded After Calling CoFreeUnusedLibraries (301357)
The information in this article applies to:
- Microsoft COM, when used with:
- the operating system: Microsoft Windows 95
- the operating system: Microsoft Windows 98
- the operating system: Microsoft Windows Millennium Edition
- the operating system: Microsoft Windows 2000
- the operating system: Microsoft Windows NT 4.0
This article was previously published under Q301357 SYMPTOMS
Dynamic-link libraries (DLLs) that are not in use may not be unloaded from the process space after calling the CoFreeUnusedLibraries function.
CAUSE
This problem occurs when the application still has references to the components in the DLL, or when the application releases all the references to a DLL but does not make a subsequent call to CoFreeUnusedLibraries.
RESOLUTIONCoFreeUnusedLibraries does not immediately release DLLs that have no active object. There is a ten minute delay for multithreaded apartments (MTAs) and neutral apartments (NAs). For single-threaded apartments (STAs), there is no delay. The ten minute delay for CoFreeUnusedLibraries is to avoid multithread race conditions caused by unloading a component DLL.
To work around the problem, make a second call to CoFreeUnusedLibraries after ten minutes, or make periodic calls to CoFreeUnusedLibraries. For applications that run for long periods, such as Windows NT Service applications, calling CoFreeUnusedLibraries periodically ensures that DLLs that are not being used are unloaded.
Another workaround is to call CoUninitialize, which closes the COM library and releases all resources used by the current thread.
STATUS
This behavior is by design.
REFERENCES
Process Explorer is available from the following Web site:
The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products. Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
Modification Type: | Minor | Last Reviewed: | 11/22/2005 |
---|
Keywords: | kbprb KB301357 |
---|
|