PRB: Memory Leak In COM When Repeatedly Creating STA Threads (289640)
The information in this article applies to:
- Microsoft COM+ 1.0
- Microsoft COM+ 1.5
This article was previously published under Q289640 SYMPTOMS
If you perform the following steps in a COM application repeatedly, a memory leak occurs:
- Create a new worker thread.
- Inside the worker thread, call CoInitialize(NULL) to initialize COM for single-threaded apartment (STA) concurrency model.
- After calling CoInitialize(NULL), create a new COM object using CoCreateInstance or CoCreateInstanceEx.
- Marshal the COM object using CoMarshalInterface into an IStream object.
- Release the marshaled COM object and associated IStream object data.
- Call CoUninitialize() and let the thread exit.
The following steps can also trigger a memory leak:
- Create a new worker thread.
- Inside the worker thread, call CoInitialize(NULL) to initialize COM for single threaded apartment (STA) concurrency model.
- After calling CoInitialize(NULL), unmarshal a previously marshaled COM object.
- Release the unmarshaled COM object and associated data.
- Call CoUninitialize() and let the thread exit.
RESOLUTION
This memory buildup does not occur if you initialize COM on the thread using CoInitializeEx(NULL,COINIT_MULTITHREADED).
Modification Type: | Major | Last Reviewed: | 9/25/2002 |
---|
Keywords: | kbBug kbDSupport kbprb KB289640 |
---|
|