PRB: IClientSecurity::CopyProxy() Leaks Memory (216248)
The information in this article applies to:
- Microsoft Windows 95, when used with:
- Microsoft Windows 98, when used with:
- Microsoft Windows NT Server 4.0, when used with:
- Microsoft Windows NT Workstation 4.0, when used with:
This article was previously published under Q216248 SYMPTOMS
IClientSecurity::CopyProxy() can appear to leak memory, as much as 2 KB per call. The symptom is usually seen when a thread is executing a tight loop of calls to CopyProxy(). The sequence would include the following calls: - After obtaining the initial interface pointer to a component, QueryInterface() for IID_ICLientSecurity.
- Use the IClientSecurity pointer, for example, pCS, to call pCS, then CopyProxy() on the original interface (proxy).
- Release() the returned proxy interface pointer.
- Release() the pCS (IClientSecurity *).
- Repeat the above steps.
::CoCopyProxy() also exhibits this behavior because it is a wrapper for the above steps.
The MORE INFORMATION section below contains sample code that demonstrates the problem.
CAUSE
There is actually no "leak" per se; a delay in memory deallocation is causing the symptom. This delay can cause the client process's private bytes memory usage to climb to unacceptable levels in large numbers of iterations.
The appearance of a leak is caused by the following:
The proxy manager for a process aggregates all interface proxy objects. Therefore, when Release() is called on the interface proxy object the proxy manager is actually receiving the Release() call. The proxy manager doesn't actually free the interface proxy object until the final release of the proxy manager. Therefore, the memory usage in the client eventually subsides when the last Release() is called on the last copy of the interface proxy object [that is, the proxy manager receives the final Release()].
RESOLUTION
One way to work around this behavior, is to cache a number of copies of the proxy to be used as needed instead of creating and releasing each time one is needed. For example, you may create a copy of the proxy and apply certain security settings to it. For all subsequent calls to the object using these security settings, you should re-use the copied proxy object, rather than copying the proxy object each time. In other words, copy the proxy object only when needed.
STATUS
Microsoft is aware of the behavior and has determined that it is by design.
REFERENCES
For more information about IClientSecurity::CopyProxy() and ::CoCopyProxy(), see the Platform SDK online documentation under "COM and ActiveX Object Services."
Please see also the Platform SDK online documentation, COM and ActiveX Object Services, COM, COM Fundamentals, Reference.
Modification Type: | Minor | Last Reviewed: | 12/21/2004 |
---|
Keywords: | kbprb kbSecurity KB216248 |
---|
|